From c4eb9a0981fe8ee6627832aa095fd03a5c0f395f Mon Sep 17 00:00:00 2001 From: kn Date: Thu, 23 Oct 2025 09:35:53 +0200 Subject: [PATCH 1/2] Add GetCreatedTimestamp and GetLastExecutionTimestamp to Build interface --- ACT/LibMCEnv.xml | 8 ++ .../HeadersDev/CppDynamic/libmcenv_dynamic.h | 24 +++++ .../CppDynamic/libmcenv_dynamic.hpp | 60 +++++++++++ Framework/InterfacesCore/libmcenv_abi.hpp | 45 ++++++++ .../InterfacesCore/libmcenv_interfaces.hpp | 12 +++ .../libmcenv_interfacewrapper.cpp | 100 ++++++++++++++++++ Implementation/LibMCEnv/libmcenv_build.cpp | 33 ++++++ Implementation/LibMCEnv/libmcenv_build.hpp | 4 + 8 files changed, 286 insertions(+) diff --git a/ACT/LibMCEnv.xml b/ACT/LibMCEnv.xml index 4cdd6085..89236aa2 100644 --- a/ACT/LibMCEnv.xml +++ b/ACT/LibMCEnv.xml @@ -2602,6 +2602,14 @@ + + + + + + + + diff --git a/Framework/HeadersDev/CppDynamic/libmcenv_dynamic.h b/Framework/HeadersDev/CppDynamic/libmcenv_dynamic.h index b2b1a1eb..789c8ed2 100644 --- a/Framework/HeadersDev/CppDynamic/libmcenv_dynamic.h +++ b/Framework/HeadersDev/CppDynamic/libmcenv_dynamic.h @@ -4260,6 +4260,28 @@ typedef LibMCEnvResult (*PLibMCEnvBuild_GetNamePtr) (LibMCEnv_Build pBuild, cons */ typedef LibMCEnvResult (*PLibMCEnvBuild_GetBuildUUIDPtr) (LibMCEnv_Build pBuild, const LibMCEnv_uint32 nBuildUUIDBufferSize, LibMCEnv_uint32* pBuildUUIDNeededChars, char * pBuildUUIDBuffer); +/** +* Returns creation timestamp of the build in ISO-8601 format. +* +* @param[in] pBuild - Build instance. +* @param[in] nTimestampBufferSize - size of the buffer (including trailing 0) +* @param[out] pTimestampNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pTimestampBuffer - buffer of Creation timestamp in ISO-8601 format (e.g., 2025-10-23T14:30:00.000Z)., may be NULL +* @return error code or 0 (success) +*/ +typedef LibMCEnvResult (*PLibMCEnvBuild_GetCreatedTimestampPtr) (LibMCEnv_Build pBuild, const LibMCEnv_uint32 nTimestampBufferSize, LibMCEnv_uint32* pTimestampNeededChars, char * pTimestampBuffer); + +/** +* Returns the most recent execution timestamp in ISO-8601 format. Returns empty string if build has never been executed. +* +* @param[in] pBuild - Build instance. +* @param[in] nTimestampBufferSize - size of the buffer (including trailing 0) +* @param[out] pTimestampNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pTimestampBuffer - buffer of Most recent execution timestamp in ISO-8601 format. Empty string if never executed., may be NULL +* @return error code or 0 (success) +*/ +typedef LibMCEnvResult (*PLibMCEnvBuild_GetLastExecutionTimestampPtr) (LibMCEnv_Build pBuild, const LibMCEnv_uint32 nTimestampBufferSize, LibMCEnv_uint32* pTimestampNeededChars, char * pTimestampBuffer); + /** * Returns storage uuid of the build stream. * @@ -11406,6 +11428,8 @@ typedef struct { PLibMCEnvBuildExecutionIterator_GetCurrentExecutionPtr m_BuildExecutionIterator_GetCurrentExecution; PLibMCEnvBuild_GetNamePtr m_Build_GetName; PLibMCEnvBuild_GetBuildUUIDPtr m_Build_GetBuildUUID; + PLibMCEnvBuild_GetCreatedTimestampPtr m_Build_GetCreatedTimestamp; + PLibMCEnvBuild_GetLastExecutionTimestampPtr m_Build_GetLastExecutionTimestamp; PLibMCEnvBuild_GetStorageUUIDPtr m_Build_GetStorageUUID; PLibMCEnvBuild_GetStorageSHA256Ptr m_Build_GetStorageSHA256; PLibMCEnvBuild_EnsureStorageSHA256IsValidPtr m_Build_EnsureStorageSHA256IsValid; diff --git a/Framework/HeadersDev/CppDynamic/libmcenv_dynamic.hpp b/Framework/HeadersDev/CppDynamic/libmcenv_dynamic.hpp index c3ae0567..08fdb74c 100644 --- a/Framework/HeadersDev/CppDynamic/libmcenv_dynamic.hpp +++ b/Framework/HeadersDev/CppDynamic/libmcenv_dynamic.hpp @@ -2248,6 +2248,8 @@ class CBuild : public CBase { inline std::string GetName(); inline std::string GetBuildUUID(); + inline std::string GetCreatedTimestamp(); + inline std::string GetLastExecutionTimestamp(); inline std::string GetStorageUUID(); inline std::string GetStorageSHA256(); inline void EnsureStorageSHA256IsValid(); @@ -4023,6 +4025,8 @@ class CUIEnvironment : public CBase { pWrapperTable->m_BuildExecutionIterator_GetCurrentExecution = nullptr; pWrapperTable->m_Build_GetName = nullptr; pWrapperTable->m_Build_GetBuildUUID = nullptr; + pWrapperTable->m_Build_GetCreatedTimestamp = nullptr; + pWrapperTable->m_Build_GetLastExecutionTimestamp = nullptr; pWrapperTable->m_Build_GetStorageUUID = nullptr; pWrapperTable->m_Build_GetStorageSHA256 = nullptr; pWrapperTable->m_Build_EnsureStorageSHA256IsValid = nullptr; @@ -8250,6 +8254,24 @@ class CUIEnvironment : public CBase { if (pWrapperTable->m_Build_GetBuildUUID == nullptr) return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_Build_GetCreatedTimestamp = (PLibMCEnvBuild_GetCreatedTimestampPtr) GetProcAddress(hLibrary, "libmcenv_build_getcreatedtimestamp"); + #else // _WIN32 + pWrapperTable->m_Build_GetCreatedTimestamp = (PLibMCEnvBuild_GetCreatedTimestampPtr) dlsym(hLibrary, "libmcenv_build_getcreatedtimestamp"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Build_GetCreatedTimestamp == nullptr) + return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_Build_GetLastExecutionTimestamp = (PLibMCEnvBuild_GetLastExecutionTimestampPtr) GetProcAddress(hLibrary, "libmcenv_build_getlastexecutiontimestamp"); + #else // _WIN32 + pWrapperTable->m_Build_GetLastExecutionTimestamp = (PLibMCEnvBuild_GetLastExecutionTimestampPtr) dlsym(hLibrary, "libmcenv_build_getlastexecutiontimestamp"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_Build_GetLastExecutionTimestamp == nullptr) + return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_Build_GetStorageUUID = (PLibMCEnvBuild_GetStorageUUIDPtr) GetProcAddress(hLibrary, "libmcenv_build_getstorageuuid"); #else // _WIN32 @@ -15521,6 +15543,14 @@ class CUIEnvironment : public CBase { if ( (eLookupError != 0) || (pWrapperTable->m_Build_GetBuildUUID == nullptr) ) return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("libmcenv_build_getcreatedtimestamp", (void**)&(pWrapperTable->m_Build_GetCreatedTimestamp)); + if ( (eLookupError != 0) || (pWrapperTable->m_Build_GetCreatedTimestamp == nullptr) ) + return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcenv_build_getlastexecutiontimestamp", (void**)&(pWrapperTable->m_Build_GetLastExecutionTimestamp)); + if ( (eLookupError != 0) || (pWrapperTable->m_Build_GetLastExecutionTimestamp == nullptr) ) + return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("libmcenv_build_getstorageuuid", (void**)&(pWrapperTable->m_Build_GetStorageUUID)); if ( (eLookupError != 0) || (pWrapperTable->m_Build_GetStorageUUID == nullptr) ) return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; @@ -23347,6 +23377,36 @@ class CUIEnvironment : public CBase { return std::string(&bufferBuildUUID[0]); } + /** + * CBuild::GetCreatedTimestamp - Returns creation timestamp of the build in ISO-8601 format. + * @return Creation timestamp in ISO-8601 format (e.g., 2025-10-23T14:30:00.000Z). + */ + std::string CBuild::GetCreatedTimestamp() + { + LibMCEnv_uint32 bytesNeededTimestamp = 0; + LibMCEnv_uint32 bytesWrittenTimestamp = 0; + CheckError(m_pWrapper->m_WrapperTable.m_Build_GetCreatedTimestamp(m_pHandle, 0, &bytesNeededTimestamp, nullptr)); + std::vector bufferTimestamp(bytesNeededTimestamp); + CheckError(m_pWrapper->m_WrapperTable.m_Build_GetCreatedTimestamp(m_pHandle, bytesNeededTimestamp, &bytesWrittenTimestamp, &bufferTimestamp[0])); + + return std::string(&bufferTimestamp[0]); + } + + /** + * CBuild::GetLastExecutionTimestamp - Returns the most recent execution timestamp in ISO-8601 format. Returns empty string if build has never been executed. + * @return Most recent execution timestamp in ISO-8601 format. Empty string if never executed. + */ + std::string CBuild::GetLastExecutionTimestamp() + { + LibMCEnv_uint32 bytesNeededTimestamp = 0; + LibMCEnv_uint32 bytesWrittenTimestamp = 0; + CheckError(m_pWrapper->m_WrapperTable.m_Build_GetLastExecutionTimestamp(m_pHandle, 0, &bytesNeededTimestamp, nullptr)); + std::vector bufferTimestamp(bytesNeededTimestamp); + CheckError(m_pWrapper->m_WrapperTable.m_Build_GetLastExecutionTimestamp(m_pHandle, bytesNeededTimestamp, &bytesWrittenTimestamp, &bufferTimestamp[0])); + + return std::string(&bufferTimestamp[0]); + } + /** * CBuild::GetStorageUUID - Returns storage uuid of the build stream. * @return Storage UUID of the build. diff --git a/Framework/InterfacesCore/libmcenv_abi.hpp b/Framework/InterfacesCore/libmcenv_abi.hpp index 6cbced6e..8a342d1f 100644 --- a/Framework/InterfacesCore/libmcenv_abi.hpp +++ b/Framework/InterfacesCore/libmcenv_abi.hpp @@ -4247,6 +4247,19 @@ LIBMCENV_DECLSPEC LibMCEnvResult libmcenv_buildexecution_loadattachedjournal(Lib */ LIBMCENV_DECLSPEC LibMCEnvResult libmcenv_buildexecutioniterator_getcurrentexecution(LibMCEnv_BuildExecutionIterator pBuildExecutionIterator, LibMCEnv_BuildExecution * pBuildExecutionInstance); +/************************************************************************************************************************* + Class definition for BuildIterator +**************************************************************************************************************************/ + +/** +* Returns the build the iterator points at. +* +* @param[in] pBuildIterator - BuildIterator instance. +* @param[out] pBuildInstance - returns the Build instance. +* @return error code or 0 (success) +*/ +LIBMCENV_DECLSPEC LibMCEnvResult libmcenv_builditerator_getcurrentbuild(LibMCEnv_BuildIterator pBuildIterator, LibMCEnv_Build * pBuildInstance); + /************************************************************************************************************************* Class definition for Build **************************************************************************************************************************/ @@ -4273,6 +4286,28 @@ LIBMCENV_DECLSPEC LibMCEnvResult libmcenv_build_getname(LibMCEnv_Build pBuild, c */ LIBMCENV_DECLSPEC LibMCEnvResult libmcenv_build_getbuilduuid(LibMCEnv_Build pBuild, const LibMCEnv_uint32 nBuildUUIDBufferSize, LibMCEnv_uint32* pBuildUUIDNeededChars, char * pBuildUUIDBuffer); +/** +* Returns creation timestamp of the build in ISO-8601 format. +* +* @param[in] pBuild - Build instance. +* @param[in] nTimestampBufferSize - size of the buffer (including trailing 0) +* @param[out] pTimestampNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pTimestampBuffer - buffer of Creation timestamp in ISO-8601 format (e.g., 2025-10-23T14:30:00.000Z)., may be NULL +* @return error code or 0 (success) +*/ +LIBMCENV_DECLSPEC LibMCEnvResult libmcenv_build_getcreatedtimestamp(LibMCEnv_Build pBuild, const LibMCEnv_uint32 nTimestampBufferSize, LibMCEnv_uint32* pTimestampNeededChars, char * pTimestampBuffer); + +/** +* Returns the most recent execution timestamp in ISO-8601 format. Returns empty string if build has never been executed. +* +* @param[in] pBuild - Build instance. +* @param[in] nTimestampBufferSize - size of the buffer (including trailing 0) +* @param[out] pTimestampNeededChars - will be filled with the count of the written bytes, or needed buffer size. +* @param[out] pTimestampBuffer - buffer of Most recent execution timestamp in ISO-8601 format. Empty string if never executed., may be NULL +* @return error code or 0 (success) +*/ +LIBMCENV_DECLSPEC LibMCEnvResult libmcenv_build_getlastexecutiontimestamp(LibMCEnv_Build pBuild, const LibMCEnv_uint32 nTimestampBufferSize, LibMCEnv_uint32* pTimestampNeededChars, char * pTimestampBuffer); + /** * Returns storage uuid of the build stream. * @@ -10600,6 +10635,16 @@ LIBMCENV_DECLSPEC LibMCEnvResult libmcenv_uienvironment_hasbuildexecution(LibMCE */ LIBMCENV_DECLSPEC LibMCEnvResult libmcenv_uienvironment_getbuildexecution(LibMCEnv_UIEnvironment pUIEnvironment, const char * pExecutionUUID, LibMCEnv_BuildExecution * pExecutionInstance); +/** +* Returns an iterator for recent build jobs, ordered by timestamp (newest first). +* +* @param[in] pUIEnvironment - UIEnvironment instance. +* @param[in] nMaxCount - Maximum number of jobs to return. Must be greater than 0. +* @param[out] pBuildIterator - Iterator for build jobs, ordered newest first. +* @return error code or 0 (success) +*/ +LIBMCENV_DECLSPEC LibMCEnvResult libmcenv_uienvironment_getrecentbuildjobs(LibMCEnv_UIEnvironment pUIEnvironment, LibMCEnv_uint32 nMaxCount, LibMCEnv_BuildIterator * pBuildIterator); + /** * Creates an empty discrete field. * diff --git a/Framework/InterfacesCore/libmcenv_interfaces.hpp b/Framework/InterfacesCore/libmcenv_interfaces.hpp index c655dd7a..a73ca078 100644 --- a/Framework/InterfacesCore/libmcenv_interfaces.hpp +++ b/Framework/InterfacesCore/libmcenv_interfaces.hpp @@ -3535,6 +3535,18 @@ class IBuild : public virtual IBase { */ virtual std::string GetBuildUUID() = 0; + /** + * IBuild::GetCreatedTimestamp - Returns creation timestamp of the build in ISO-8601 format. + * @return Creation timestamp in ISO-8601 format (e.g., 2025-10-23T14:30:00.000Z). + */ + virtual std::string GetCreatedTimestamp() = 0; + + /** + * IBuild::GetLastExecutionTimestamp - Returns the most recent execution timestamp in ISO-8601 format. Returns empty string if build has never been executed. + * @return Most recent execution timestamp in ISO-8601 format. Empty string if never executed. + */ + virtual std::string GetLastExecutionTimestamp() = 0; + /** * IBuild::GetStorageUUID - Returns storage uuid of the build stream. * @return Storage UUID of the build. diff --git a/Framework/InterfacesCore/libmcenv_interfacewrapper.cpp b/Framework/InterfacesCore/libmcenv_interfacewrapper.cpp index 2dcd6043..77328a47 100644 --- a/Framework/InterfacesCore/libmcenv_interfacewrapper.cpp +++ b/Framework/InterfacesCore/libmcenv_interfacewrapper.cpp @@ -12286,6 +12286,102 @@ LibMCEnvResult libmcenv_build_getbuilduuid(LibMCEnv_Build pBuild, const LibMCEnv } } +LibMCEnvResult libmcenv_build_getcreatedtimestamp(LibMCEnv_Build pBuild, const LibMCEnv_uint32 nTimestampBufferSize, LibMCEnv_uint32* pTimestampNeededChars, char * pTimestampBuffer) +{ + IBase* pIBaseClass = (IBase *)pBuild; + + try { + if ( (!pTimestampBuffer) && !(pTimestampNeededChars) ) + throw ELibMCEnvInterfaceException (LIBMCENV_ERROR_INVALIDPARAM); + std::string sTimestamp(""); + IBuild* pIBuild = dynamic_cast(pIBaseClass); + if (!pIBuild) + throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_INVALIDCAST); + + bool isCacheCall = (pTimestampBuffer == nullptr); + if (isCacheCall) { + sTimestamp = pIBuild->GetCreatedTimestamp(); + + pIBuild->_setCache (new ParameterCache_1 (sTimestamp)); + } + else { + auto cache = dynamic_cast*> (pIBuild->_getCache ()); + if (cache == nullptr) + throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_INVALIDCAST); + cache->retrieveData (sTimestamp); + pIBuild->_setCache (nullptr); + } + + if (pTimestampNeededChars) + *pTimestampNeededChars = (LibMCEnv_uint32) (sTimestamp.size()+1); + if (pTimestampBuffer) { + if (sTimestamp.size() >= nTimestampBufferSize) + throw ELibMCEnvInterfaceException (LIBMCENV_ERROR_BUFFERTOOSMALL); + for (size_t iTimestamp = 0; iTimestamp < sTimestamp.size(); iTimestamp++) + pTimestampBuffer[iTimestamp] = sTimestamp[iTimestamp]; + pTimestampBuffer[sTimestamp.size()] = 0; + } + return LIBMCENV_SUCCESS; + } + catch (ELibMCEnvInterfaceException & Exception) { + return handleLibMCEnvException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCEnvResult libmcenv_build_getlastexecutiontimestamp(LibMCEnv_Build pBuild, const LibMCEnv_uint32 nTimestampBufferSize, LibMCEnv_uint32* pTimestampNeededChars, char * pTimestampBuffer) +{ + IBase* pIBaseClass = (IBase *)pBuild; + + try { + if ( (!pTimestampBuffer) && !(pTimestampNeededChars) ) + throw ELibMCEnvInterfaceException (LIBMCENV_ERROR_INVALIDPARAM); + std::string sTimestamp(""); + IBuild* pIBuild = dynamic_cast(pIBaseClass); + if (!pIBuild) + throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_INVALIDCAST); + + bool isCacheCall = (pTimestampBuffer == nullptr); + if (isCacheCall) { + sTimestamp = pIBuild->GetLastExecutionTimestamp(); + + pIBuild->_setCache (new ParameterCache_1 (sTimestamp)); + } + else { + auto cache = dynamic_cast*> (pIBuild->_getCache ()); + if (cache == nullptr) + throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_INVALIDCAST); + cache->retrieveData (sTimestamp); + pIBuild->_setCache (nullptr); + } + + if (pTimestampNeededChars) + *pTimestampNeededChars = (LibMCEnv_uint32) (sTimestamp.size()+1); + if (pTimestampBuffer) { + if (sTimestamp.size() >= nTimestampBufferSize) + throw ELibMCEnvInterfaceException (LIBMCENV_ERROR_BUFFERTOOSMALL); + for (size_t iTimestamp = 0; iTimestamp < sTimestamp.size(); iTimestamp++) + pTimestampBuffer[iTimestamp] = sTimestamp[iTimestamp]; + pTimestampBuffer[sTimestamp.size()] = 0; + } + return LIBMCENV_SUCCESS; + } + catch (ELibMCEnvInterfaceException & Exception) { + return handleLibMCEnvException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + LibMCEnvResult libmcenv_build_getstorageuuid(LibMCEnv_Build pBuild, const LibMCEnv_uint32 nStorageUUIDBufferSize, LibMCEnv_uint32* pStorageUUIDNeededChars, char * pStorageUUIDBuffer) { IBase* pIBaseClass = (IBase *)pBuild; @@ -33871,6 +33967,10 @@ LibMCEnvResult LibMCEnv::Impl::LibMCEnv_GetProcAddress (const char * pProcName, *ppProcAddress = (void*) &libmcenv_build_getname; if (sProcName == "libmcenv_build_getbuilduuid") *ppProcAddress = (void*) &libmcenv_build_getbuilduuid; + if (sProcName == "libmcenv_build_getcreatedtimestamp") + *ppProcAddress = (void*) &libmcenv_build_getcreatedtimestamp; + if (sProcName == "libmcenv_build_getlastexecutiontimestamp") + *ppProcAddress = (void*) &libmcenv_build_getlastexecutiontimestamp; if (sProcName == "libmcenv_build_getstorageuuid") *ppProcAddress = (void*) &libmcenv_build_getstorageuuid; if (sProcName == "libmcenv_build_getstoragesha256") diff --git a/Implementation/LibMCEnv/libmcenv_build.cpp b/Implementation/LibMCEnv/libmcenv_build.cpp index d7b3dd6d..d3836a86 100644 --- a/Implementation/LibMCEnv/libmcenv_build.cpp +++ b/Implementation/LibMCEnv/libmcenv_build.cpp @@ -95,6 +95,39 @@ std::string CBuild::GetBuildUUID() return pBuildJob->GetUUID(); } +std::string CBuild::GetCreatedTimestamp() +{ + auto pBuildJobHandler = m_pDataModel->CreateBuildJobHandler(); + auto pBuildJob = pBuildJobHandler->RetrieveJob(m_sBuildJobUUID); + return pBuildJob->GetTimeStamp(); +} + +std::string CBuild::GetLastExecutionTimestamp() +{ + auto pBuildJobHandler = m_pDataModel->CreateBuildJobHandler(); + auto pBuildJob = pBuildJobHandler->RetrieveJob(m_sBuildJobUUID); + + // Find the latest execution timestamp + std::string sLatestExecutionTime = ""; + uint64_t nLatestExecutionMicroseconds = 0; + + auto pJobExecutionIterator = pBuildJob->RetrieveBuildJobExecutions(""); + while (pJobExecutionIterator->MoveNext()) { + auto pJobExecution = pJobExecutionIterator->GetCurrentJobExecution(); + uint64_t nExecutionTime = pJobExecution->GetStartTimeStampInMicroseconds(); + if (nExecutionTime > nLatestExecutionMicroseconds) { + nLatestExecutionMicroseconds = nExecutionTime; + } + } + + // Convert to ISO 8601 format if we found any executions + if (nLatestExecutionMicroseconds > 0) { + sLatestExecutionTime = AMCCommon::CChrono::convertToISO8601TimeUTC(nLatestExecutionMicroseconds); + } + + return sLatestExecutionTime; +} + std::string CBuild::GetStorageUUID() { auto pBuildJobHandler = m_pDataModel->CreateBuildJobHandler(); diff --git a/Implementation/LibMCEnv/libmcenv_build.hpp b/Implementation/LibMCEnv/libmcenv_build.hpp index de140f2f..bdae825f 100644 --- a/Implementation/LibMCEnv/libmcenv_build.hpp +++ b/Implementation/LibMCEnv/libmcenv_build.hpp @@ -77,6 +77,10 @@ class CBuild : public virtual IBuild, public virtual CBase { std::string GetBuildUUID() override; + std::string GetCreatedTimestamp() override; + + std::string GetLastExecutionTimestamp() override; + std::string GetStorageUUID() override; std::string GetStorageSHA256() override; From e6a8347ffc3d98381340c9002223dbd2c23e3cbc Mon Sep 17 00:00:00 2001 From: kn Date: Wed, 22 Oct 2025 21:51:23 +0200 Subject: [PATCH 2/2] Feature: Add GetRecentBuildJobs() API to UIEnvironment Add new API method to retrieve recent validated build jobs for touchscreen UI display. Changes: 1. **IDL Definition** (ACT/LibMCEnv.xml): - Added BuildIterator class following BuildExecutionIterator pattern - Added GetRecentBuildJobs(maxCount) method to UIEnvironment 2. **BuildIterator Implementation**: - New class CBuildIterator (libmcenv_builditerator.hpp/cpp) - Implements GetCurrentBuild() to return IBuild instances - Follows standard AMCF iterator pattern 3. **UIEnvironment Implementation** (libmcenv_uienvironment.cpp): - GetRecentBuildJobs() queries validated build jobs via DataModel - Returns BuildIterator with most recent jobs (newest first) - Limited by maxCount parameter 4. **CBuild Factory Methods** (libmcenv_build.cpp/hpp): - Added makeFrom() and makeSharedFrom() static methods - Enables BuildIterator to wrap existing build job instances This API enables plugins to access build job data for UI display without direct DataModel access, maintaining proper abstraction. --- InterfacesCode: Regenerate interface files from ACT for GetRecentBuildJobs API Regenerated C++ interface bindings and headers using ACT (Automatic Component Toolkit) after adding GetRecentBuildJobs() method to LibMCEnv.xml. Generated/Updated files: - Framework/HeadersDev/CppDynamic/libmcenv_dynamic.hpp - Framework/HeadersDev/CppDynamic/libmcenv_dynamic.h - Framework/HeadersDev/CppDynamic/libmcenv_types.hpp - Framework/InterfacesCore/libmcenv_abi.hpp - Framework/InterfacesCore/libmcenv_interfaces.hpp - Framework/InterfacesCore/libmcenv_interfacewrapper.cpp - Framework/InterfacesCore/libmcenv_types.hpp - ACT/act.linux (binary timestamp update) These files are auto-generated by running: ./act.linux LibMCEnv.xml --- ACT/LibMCEnv.xml | 30 +++ ACT/act.linux | Bin .../HeadersDev/CppDynamic/libmcenv_dynamic.h | 69 +++++++ .../CppDynamic/libmcenv_dynamic.hpp | 186 ++++++++++++++++++ .../HeadersDev/CppDynamic/libmcenv_types.hpp | 1 + Framework/InterfacesCore/libmcenv_abi.hpp | 40 ++++ .../InterfacesCore/libmcenv_interfaces.hpp | 53 +++++ .../libmcenv_interfacewrapper.cpp | 183 +++++++++++++++++ Framework/InterfacesCore/libmcenv_types.hpp | 1 + Implementation/LibMCEnv/libmcenv_build.cpp | 13 ++ Implementation/LibMCEnv/libmcenv_build.hpp | 4 + .../LibMCEnv/libmcenv_builditerator.cpp | 97 +++++++++ .../LibMCEnv/libmcenv_builditerator.hpp | 82 ++++++++ .../LibMCEnv/libmcenv_uienvironment.cpp | 90 +++++++++ .../LibMCEnv/libmcenv_uienvironment.hpp | 11 ++ 15 files changed, 860 insertions(+) mode change 100644 => 100755 ACT/act.linux create mode 100644 Implementation/LibMCEnv/libmcenv_builditerator.cpp create mode 100644 Implementation/LibMCEnv/libmcenv_builditerator.hpp diff --git a/ACT/LibMCEnv.xml b/ACT/LibMCEnv.xml index 89236aa2..e917198b 100644 --- a/ACT/LibMCEnv.xml +++ b/ACT/LibMCEnv.xml @@ -2591,6 +2591,12 @@ + + + + + + @@ -5737,6 +5743,10 @@ + + + + @@ -5908,6 +5918,26 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/ACT/act.linux b/ACT/act.linux old mode 100644 new mode 100755 diff --git a/Framework/HeadersDev/CppDynamic/libmcenv_dynamic.h b/Framework/HeadersDev/CppDynamic/libmcenv_dynamic.h index 789c8ed2..fa733e99 100644 --- a/Framework/HeadersDev/CppDynamic/libmcenv_dynamic.h +++ b/Framework/HeadersDev/CppDynamic/libmcenv_dynamic.h @@ -4234,6 +4234,19 @@ typedef LibMCEnvResult (*PLibMCEnvBuildExecution_LoadAttachedJournalPtr) (LibMCE */ typedef LibMCEnvResult (*PLibMCEnvBuildExecutionIterator_GetCurrentExecutionPtr) (LibMCEnv_BuildExecutionIterator pBuildExecutionIterator, LibMCEnv_BuildExecution * pBuildExecutionInstance); +/************************************************************************************************************************* + Class definition for BuildIterator +**************************************************************************************************************************/ + +/** +* Returns the build the iterator points at. +* +* @param[in] pBuildIterator - BuildIterator instance. +* @param[out] pBuildInstance - returns the Build instance. +* @return error code or 0 (success) +*/ +typedef LibMCEnvResult (*PLibMCEnvBuildIterator_GetCurrentBuildPtr) (LibMCEnv_BuildIterator pBuildIterator, LibMCEnv_Build * pBuildInstance); + /************************************************************************************************************************* Class definition for Build **************************************************************************************************************************/ @@ -10609,6 +10622,16 @@ typedef LibMCEnvResult (*PLibMCEnvUIEnvironment_HasBuildExecutionPtr) (LibMCEnv_ */ typedef LibMCEnvResult (*PLibMCEnvUIEnvironment_GetBuildExecutionPtr) (LibMCEnv_UIEnvironment pUIEnvironment, const char * pExecutionUUID, LibMCEnv_BuildExecution * pExecutionInstance); +/** +* Returns an iterator for recent build jobs, ordered by timestamp (newest first). +* +* @param[in] pUIEnvironment - UIEnvironment instance. +* @param[in] nMaxCount - Maximum number of jobs to return. Must be greater than 0. +* @param[out] pBuildIterator - Iterator for build jobs, ordered newest first. +* @return error code or 0 (success) +*/ +typedef LibMCEnvResult (*PLibMCEnvUIEnvironment_GetRecentBuildJobsPtr) (LibMCEnv_UIEnvironment pUIEnvironment, LibMCEnv_uint32 nMaxCount, LibMCEnv_BuildIterator * pBuildIterator); + /** * Creates an empty discrete field. * @@ -10951,6 +10974,46 @@ typedef LibMCEnvResult (*PLibMCEnvUIEnvironment_GetExternalEventParameterPtr) (L */ typedef LibMCEnvResult (*PLibMCEnvUIEnvironment_AddExternalEventResultValuePtr) (LibMCEnv_UIEnvironment pUIEnvironment, const char * pReturnValueName, const char * pReturnValue); +/** +* Sets a string result value for external event return (typed convenience wrapper). +* +* @param[in] pUIEnvironment - UIEnvironment instance. +* @param[in] pReturnValueName - The name of the return parameter. MUST be an alphanumeric ASCII string (with optional _ and -) +* @param[in] pReturnValue - Return value. +* @return error code or 0 (success) +*/ +typedef LibMCEnvResult (*PLibMCEnvUIEnvironment_SetStringResultPtr) (LibMCEnv_UIEnvironment pUIEnvironment, const char * pReturnValueName, const char * pReturnValue); + +/** +* Sets an integer result value for external event return. +* +* @param[in] pUIEnvironment - UIEnvironment instance. +* @param[in] pReturnValueName - The name of the return parameter. MUST be an alphanumeric ASCII string (with optional _ and -) +* @param[in] nReturnValue - Return value. +* @return error code or 0 (success) +*/ +typedef LibMCEnvResult (*PLibMCEnvUIEnvironment_SetIntegerResultPtr) (LibMCEnv_UIEnvironment pUIEnvironment, const char * pReturnValueName, LibMCEnv_int64 nReturnValue); + +/** +* Sets a boolean result value for external event return. +* +* @param[in] pUIEnvironment - UIEnvironment instance. +* @param[in] pReturnValueName - The name of the return parameter. MUST be an alphanumeric ASCII string (with optional _ and -) +* @param[in] bReturnValue - Return value. +* @return error code or 0 (success) +*/ +typedef LibMCEnvResult (*PLibMCEnvUIEnvironment_SetBoolResultPtr) (LibMCEnv_UIEnvironment pUIEnvironment, const char * pReturnValueName, bool bReturnValue); + +/** +* Sets a double result value for external event return. +* +* @param[in] pUIEnvironment - UIEnvironment instance. +* @param[in] pReturnValueName - The name of the return parameter. MUST be an alphanumeric ASCII string (with optional _ and -) +* @param[in] dReturnValue - Return value. +* @return error code or 0 (success) +*/ +typedef LibMCEnvResult (*PLibMCEnvUIEnvironment_SetDoubleResultPtr) (LibMCEnv_UIEnvironment pUIEnvironment, const char * pReturnValueName, LibMCEnv_double dReturnValue); + /** * Returns the external event parameters. This JSON Object was passed on from the external API. * @@ -11426,6 +11489,7 @@ typedef struct { PLibMCEnvBuildExecution_GetMetaDataStringPtr m_BuildExecution_GetMetaDataString; PLibMCEnvBuildExecution_LoadAttachedJournalPtr m_BuildExecution_LoadAttachedJournal; PLibMCEnvBuildExecutionIterator_GetCurrentExecutionPtr m_BuildExecutionIterator_GetCurrentExecution; + PLibMCEnvBuildIterator_GetCurrentBuildPtr m_BuildIterator_GetCurrentBuild; PLibMCEnvBuild_GetNamePtr m_Build_GetName; PLibMCEnvBuild_GetBuildUUIDPtr m_Build_GetBuildUUID; PLibMCEnvBuild_GetCreatedTimestampPtr m_Build_GetCreatedTimestamp; @@ -12021,6 +12085,7 @@ typedef struct { PLibMCEnvUIEnvironment_GetBuildJobPtr m_UIEnvironment_GetBuildJob; PLibMCEnvUIEnvironment_HasBuildExecutionPtr m_UIEnvironment_HasBuildExecution; PLibMCEnvUIEnvironment_GetBuildExecutionPtr m_UIEnvironment_GetBuildExecution; + PLibMCEnvUIEnvironment_GetRecentBuildJobsPtr m_UIEnvironment_GetRecentBuildJobs; PLibMCEnvUIEnvironment_CreateDiscreteField2DPtr m_UIEnvironment_CreateDiscreteField2D; PLibMCEnvUIEnvironment_CreateDiscreteField2DFromImagePtr m_UIEnvironment_CreateDiscreteField2DFromImage; PLibMCEnvUIEnvironment_CheckPermissionPtr m_UIEnvironment_CheckPermission; @@ -12053,6 +12118,10 @@ typedef struct { PLibMCEnvUIEnvironment_HasExternalEventParameterPtr m_UIEnvironment_HasExternalEventParameter; PLibMCEnvUIEnvironment_GetExternalEventParameterPtr m_UIEnvironment_GetExternalEventParameter; PLibMCEnvUIEnvironment_AddExternalEventResultValuePtr m_UIEnvironment_AddExternalEventResultValue; + PLibMCEnvUIEnvironment_SetStringResultPtr m_UIEnvironment_SetStringResult; + PLibMCEnvUIEnvironment_SetIntegerResultPtr m_UIEnvironment_SetIntegerResult; + PLibMCEnvUIEnvironment_SetBoolResultPtr m_UIEnvironment_SetBoolResult; + PLibMCEnvUIEnvironment_SetDoubleResultPtr m_UIEnvironment_SetDoubleResult; PLibMCEnvUIEnvironment_GetExternalEventParametersPtr m_UIEnvironment_GetExternalEventParameters; PLibMCEnvUIEnvironment_GetExternalEventResultsPtr m_UIEnvironment_GetExternalEventResults; PLibMCEnvUIEnvironment_CreateMachineConfigurationHandlerPtr m_UIEnvironment_CreateMachineConfigurationHandler; diff --git a/Framework/HeadersDev/CppDynamic/libmcenv_dynamic.hpp b/Framework/HeadersDev/CppDynamic/libmcenv_dynamic.hpp index 08fdb74c..eaeb36a1 100644 --- a/Framework/HeadersDev/CppDynamic/libmcenv_dynamic.hpp +++ b/Framework/HeadersDev/CppDynamic/libmcenv_dynamic.hpp @@ -97,6 +97,7 @@ class CToolpathLayer; class CToolpathAccessor; class CBuildExecution; class CBuildExecutionIterator; +class CBuildIterator; class CBuild; class CWorkingFileProcess; class CWorkingFile; @@ -183,6 +184,7 @@ typedef CToolpathLayer CLibMCEnvToolpathLayer; typedef CToolpathAccessor CLibMCEnvToolpathAccessor; typedef CBuildExecution CLibMCEnvBuildExecution; typedef CBuildExecutionIterator CLibMCEnvBuildExecutionIterator; +typedef CBuildIterator CLibMCEnvBuildIterator; typedef CBuild CLibMCEnvBuild; typedef CWorkingFileProcess CLibMCEnvWorkingFileProcess; typedef CWorkingFile CLibMCEnvWorkingFile; @@ -269,6 +271,7 @@ typedef std::shared_ptr PToolpathLayer; typedef std::shared_ptr PToolpathAccessor; typedef std::shared_ptr PBuildExecution; typedef std::shared_ptr PBuildExecutionIterator; +typedef std::shared_ptr PBuildIterator; typedef std::shared_ptr PBuild; typedef std::shared_ptr PWorkingFileProcess; typedef std::shared_ptr PWorkingFile; @@ -355,6 +358,7 @@ typedef PToolpathLayer PLibMCEnvToolpathLayer; typedef PToolpathAccessor PLibMCEnvToolpathAccessor; typedef PBuildExecution PLibMCEnvBuildExecution; typedef PBuildExecutionIterator PLibMCEnvBuildExecutionIterator; +typedef PBuildIterator PLibMCEnvBuildIterator; typedef PBuild PLibMCEnvBuild; typedef PWorkingFileProcess PLibMCEnvWorkingFileProcess; typedef PWorkingFile PLibMCEnvWorkingFile; @@ -1145,6 +1149,7 @@ class CWrapper { friend class CToolpathAccessor; friend class CBuildExecution; friend class CBuildExecutionIterator; + friend class CBuildIterator; friend class CBuild; friend class CWorkingFileProcess; friend class CWorkingFile; @@ -2232,6 +2237,23 @@ class CBuildExecutionIterator : public CIterator { inline PBuildExecution GetCurrentExecution(); }; +/************************************************************************************************************************* + Class CBuildIterator +**************************************************************************************************************************/ +class CBuildIterator : public CIterator { +public: + + /** + * CBuildIterator::CBuildIterator - Constructor for BuildIterator class. + */ + CBuildIterator(CWrapper* pWrapper, LibMCEnvHandle pHandle) + : CIterator(pWrapper, pHandle) + { + } + + inline PBuild GetCurrentBuild(); +}; + /************************************************************************************************************************* Class CBuild **************************************************************************************************************************/ @@ -3513,6 +3535,7 @@ class CUIEnvironment : public CBase { inline PBuild GetBuildJob(const std::string & sBuildUUID); inline bool HasBuildExecution(const std::string & sExecutionUUID); inline PBuildExecution GetBuildExecution(const std::string & sExecutionUUID); + inline PBuildIterator GetRecentBuildJobs(const LibMCEnv_uint32 nMaxCount); inline PDiscreteFieldData2D CreateDiscreteField2D(const LibMCEnv_uint32 nPixelCountX, const LibMCEnv_uint32 nPixelCountY, const LibMCEnv_double dDPIValueX, const LibMCEnv_double dDPIValueY, const LibMCEnv_double dOriginX, const LibMCEnv_double dOriginY, const LibMCEnv_double dDefaultValue); inline PDiscreteFieldData2D CreateDiscreteField2DFromImage(classParam pImageDataInstance, const LibMCEnv_double dBlackValue, const LibMCEnv_double dWhiteValue, const LibMCEnv_double dOriginX, const LibMCEnv_double dOriginY); inline bool CheckPermission(const std::string & sPermissionIdentifier); @@ -3545,6 +3568,10 @@ class CUIEnvironment : public CBase { inline bool HasExternalEventParameter(const std::string & sParameterName); inline std::string GetExternalEventParameter(const std::string & sParameterName); inline void AddExternalEventResultValue(const std::string & sReturnValueName, const std::string & sReturnValue); + inline void SetStringResult(const std::string & sReturnValueName, const std::string & sReturnValue); + inline void SetIntegerResult(const std::string & sReturnValueName, const LibMCEnv_int64 nReturnValue); + inline void SetBoolResult(const std::string & sReturnValueName, const bool bReturnValue); + inline void SetDoubleResult(const std::string & sReturnValueName, const LibMCEnv_double dReturnValue); inline PJSONObject GetExternalEventParameters(); inline PJSONObject GetExternalEventResults(); inline PMachineConfigurationHandler CreateMachineConfigurationHandler(); @@ -4023,6 +4050,7 @@ class CUIEnvironment : public CBase { pWrapperTable->m_BuildExecution_GetMetaDataString = nullptr; pWrapperTable->m_BuildExecution_LoadAttachedJournal = nullptr; pWrapperTable->m_BuildExecutionIterator_GetCurrentExecution = nullptr; + pWrapperTable->m_BuildIterator_GetCurrentBuild = nullptr; pWrapperTable->m_Build_GetName = nullptr; pWrapperTable->m_Build_GetBuildUUID = nullptr; pWrapperTable->m_Build_GetCreatedTimestamp = nullptr; @@ -4618,6 +4646,7 @@ class CUIEnvironment : public CBase { pWrapperTable->m_UIEnvironment_GetBuildJob = nullptr; pWrapperTable->m_UIEnvironment_HasBuildExecution = nullptr; pWrapperTable->m_UIEnvironment_GetBuildExecution = nullptr; + pWrapperTable->m_UIEnvironment_GetRecentBuildJobs = nullptr; pWrapperTable->m_UIEnvironment_CreateDiscreteField2D = nullptr; pWrapperTable->m_UIEnvironment_CreateDiscreteField2DFromImage = nullptr; pWrapperTable->m_UIEnvironment_CheckPermission = nullptr; @@ -4650,6 +4679,10 @@ class CUIEnvironment : public CBase { pWrapperTable->m_UIEnvironment_HasExternalEventParameter = nullptr; pWrapperTable->m_UIEnvironment_GetExternalEventParameter = nullptr; pWrapperTable->m_UIEnvironment_AddExternalEventResultValue = nullptr; + pWrapperTable->m_UIEnvironment_SetStringResult = nullptr; + pWrapperTable->m_UIEnvironment_SetIntegerResult = nullptr; + pWrapperTable->m_UIEnvironment_SetBoolResult = nullptr; + pWrapperTable->m_UIEnvironment_SetDoubleResult = nullptr; pWrapperTable->m_UIEnvironment_GetExternalEventParameters = nullptr; pWrapperTable->m_UIEnvironment_GetExternalEventResults = nullptr; pWrapperTable->m_UIEnvironment_CreateMachineConfigurationHandler = nullptr; @@ -8236,6 +8269,15 @@ class CUIEnvironment : public CBase { if (pWrapperTable->m_BuildExecutionIterator_GetCurrentExecution == nullptr) return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_BuildIterator_GetCurrentBuild = (PLibMCEnvBuildIterator_GetCurrentBuildPtr) GetProcAddress(hLibrary, "libmcenv_builditerator_getcurrentbuild"); + #else // _WIN32 + pWrapperTable->m_BuildIterator_GetCurrentBuild = (PLibMCEnvBuildIterator_GetCurrentBuildPtr) dlsym(hLibrary, "libmcenv_builditerator_getcurrentbuild"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_BuildIterator_GetCurrentBuild == nullptr) + return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_Build_GetName = (PLibMCEnvBuild_GetNamePtr) GetProcAddress(hLibrary, "libmcenv_build_getname"); #else // _WIN32 @@ -13591,6 +13633,15 @@ class CUIEnvironment : public CBase { if (pWrapperTable->m_UIEnvironment_GetBuildExecution == nullptr) return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_UIEnvironment_GetRecentBuildJobs = (PLibMCEnvUIEnvironment_GetRecentBuildJobsPtr) GetProcAddress(hLibrary, "libmcenv_uienvironment_getrecentbuildjobs"); + #else // _WIN32 + pWrapperTable->m_UIEnvironment_GetRecentBuildJobs = (PLibMCEnvUIEnvironment_GetRecentBuildJobsPtr) dlsym(hLibrary, "libmcenv_uienvironment_getrecentbuildjobs"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_UIEnvironment_GetRecentBuildJobs == nullptr) + return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_UIEnvironment_CreateDiscreteField2D = (PLibMCEnvUIEnvironment_CreateDiscreteField2DPtr) GetProcAddress(hLibrary, "libmcenv_uienvironment_creatediscretefield2d"); #else // _WIN32 @@ -13879,6 +13930,42 @@ class CUIEnvironment : public CBase { if (pWrapperTable->m_UIEnvironment_AddExternalEventResultValue == nullptr) return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 + pWrapperTable->m_UIEnvironment_SetStringResult = (PLibMCEnvUIEnvironment_SetStringResultPtr) GetProcAddress(hLibrary, "libmcenv_uienvironment_setstringresult"); + #else // _WIN32 + pWrapperTable->m_UIEnvironment_SetStringResult = (PLibMCEnvUIEnvironment_SetStringResultPtr) dlsym(hLibrary, "libmcenv_uienvironment_setstringresult"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_UIEnvironment_SetStringResult == nullptr) + return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_UIEnvironment_SetIntegerResult = (PLibMCEnvUIEnvironment_SetIntegerResultPtr) GetProcAddress(hLibrary, "libmcenv_uienvironment_setintegerresult"); + #else // _WIN32 + pWrapperTable->m_UIEnvironment_SetIntegerResult = (PLibMCEnvUIEnvironment_SetIntegerResultPtr) dlsym(hLibrary, "libmcenv_uienvironment_setintegerresult"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_UIEnvironment_SetIntegerResult == nullptr) + return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_UIEnvironment_SetBoolResult = (PLibMCEnvUIEnvironment_SetBoolResultPtr) GetProcAddress(hLibrary, "libmcenv_uienvironment_setboolresult"); + #else // _WIN32 + pWrapperTable->m_UIEnvironment_SetBoolResult = (PLibMCEnvUIEnvironment_SetBoolResultPtr) dlsym(hLibrary, "libmcenv_uienvironment_setboolresult"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_UIEnvironment_SetBoolResult == nullptr) + return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; + + #ifdef _WIN32 + pWrapperTable->m_UIEnvironment_SetDoubleResult = (PLibMCEnvUIEnvironment_SetDoubleResultPtr) GetProcAddress(hLibrary, "libmcenv_uienvironment_setdoubleresult"); + #else // _WIN32 + pWrapperTable->m_UIEnvironment_SetDoubleResult = (PLibMCEnvUIEnvironment_SetDoubleResultPtr) dlsym(hLibrary, "libmcenv_uienvironment_setdoubleresult"); + dlerror(); + #endif // _WIN32 + if (pWrapperTable->m_UIEnvironment_SetDoubleResult == nullptr) + return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; + #ifdef _WIN32 pWrapperTable->m_UIEnvironment_GetExternalEventParameters = (PLibMCEnvUIEnvironment_GetExternalEventParametersPtr) GetProcAddress(hLibrary, "libmcenv_uienvironment_getexternaleventparameters"); #else // _WIN32 @@ -15535,6 +15622,10 @@ class CUIEnvironment : public CBase { if ( (eLookupError != 0) || (pWrapperTable->m_BuildExecutionIterator_GetCurrentExecution == nullptr) ) return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("libmcenv_builditerator_getcurrentbuild", (void**)&(pWrapperTable->m_BuildIterator_GetCurrentBuild)); + if ( (eLookupError != 0) || (pWrapperTable->m_BuildIterator_GetCurrentBuild == nullptr) ) + return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("libmcenv_build_getname", (void**)&(pWrapperTable->m_Build_GetName)); if ( (eLookupError != 0) || (pWrapperTable->m_Build_GetName == nullptr) ) return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; @@ -17915,6 +18006,10 @@ class CUIEnvironment : public CBase { if ( (eLookupError != 0) || (pWrapperTable->m_UIEnvironment_GetBuildExecution == nullptr) ) return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("libmcenv_uienvironment_getrecentbuildjobs", (void**)&(pWrapperTable->m_UIEnvironment_GetRecentBuildJobs)); + if ( (eLookupError != 0) || (pWrapperTable->m_UIEnvironment_GetRecentBuildJobs == nullptr) ) + return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("libmcenv_uienvironment_creatediscretefield2d", (void**)&(pWrapperTable->m_UIEnvironment_CreateDiscreteField2D)); if ( (eLookupError != 0) || (pWrapperTable->m_UIEnvironment_CreateDiscreteField2D == nullptr) ) return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; @@ -18043,6 +18138,22 @@ class CUIEnvironment : public CBase { if ( (eLookupError != 0) || (pWrapperTable->m_UIEnvironment_AddExternalEventResultValue == nullptr) ) return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("libmcenv_uienvironment_setstringresult", (void**)&(pWrapperTable->m_UIEnvironment_SetStringResult)); + if ( (eLookupError != 0) || (pWrapperTable->m_UIEnvironment_SetStringResult == nullptr) ) + return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcenv_uienvironment_setintegerresult", (void**)&(pWrapperTable->m_UIEnvironment_SetIntegerResult)); + if ( (eLookupError != 0) || (pWrapperTable->m_UIEnvironment_SetIntegerResult == nullptr) ) + return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcenv_uienvironment_setboolresult", (void**)&(pWrapperTable->m_UIEnvironment_SetBoolResult)); + if ( (eLookupError != 0) || (pWrapperTable->m_UIEnvironment_SetBoolResult == nullptr) ) + return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; + + eLookupError = (*pLookup)("libmcenv_uienvironment_setdoubleresult", (void**)&(pWrapperTable->m_UIEnvironment_SetDoubleResult)); + if ( (eLookupError != 0) || (pWrapperTable->m_UIEnvironment_SetDoubleResult == nullptr) ) + return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; + eLookupError = (*pLookup)("libmcenv_uienvironment_getexternaleventparameters", (void**)&(pWrapperTable->m_UIEnvironment_GetExternalEventParameters)); if ( (eLookupError != 0) || (pWrapperTable->m_UIEnvironment_GetExternalEventParameters == nullptr) ) return LIBMCENV_ERROR_COULDNOTFINDLIBRARYEXPORT; @@ -23343,6 +23454,25 @@ class CUIEnvironment : public CBase { return std::make_shared(m_pWrapper, hBuildExecutionInstance); } + /** + * Method definitions for class CBuildIterator + */ + + /** + * CBuildIterator::GetCurrentBuild - Returns the build the iterator points at. + * @return returns the Build instance. + */ + PBuild CBuildIterator::GetCurrentBuild() + { + LibMCEnvHandle hBuildInstance = nullptr; + CheckError(m_pWrapper->m_WrapperTable.m_BuildIterator_GetCurrentBuild(m_pHandle, &hBuildInstance)); + + if (!hBuildInstance) { + CheckError(LIBMCENV_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hBuildInstance); + } + /** * Method definitions for class CBuild */ @@ -31695,6 +31825,22 @@ class CUIEnvironment : public CBase { return std::make_shared(m_pWrapper, hExecutionInstance); } + /** + * CUIEnvironment::GetRecentBuildJobs - Returns an iterator for recent build jobs, ordered by timestamp (newest first). + * @param[in] nMaxCount - Maximum number of jobs to return. Must be greater than 0. + * @return Iterator for build jobs, ordered newest first. + */ + PBuildIterator CUIEnvironment::GetRecentBuildJobs(const LibMCEnv_uint32 nMaxCount) + { + LibMCEnvHandle hBuildIterator = nullptr; + CheckError(m_pWrapper->m_WrapperTable.m_UIEnvironment_GetRecentBuildJobs(m_pHandle, nMaxCount, &hBuildIterator)); + + if (!hBuildIterator) { + CheckError(LIBMCENV_ERROR_INVALIDPARAM); + } + return std::make_shared(m_pWrapper, hBuildIterator); + } + /** * CUIEnvironment::CreateDiscreteField2D - Creates an empty discrete field. * @param[in] nPixelCountX - Pixel count in X. MUST be positive. @@ -32186,6 +32332,46 @@ class CUIEnvironment : public CBase { CheckError(m_pWrapper->m_WrapperTable.m_UIEnvironment_AddExternalEventResultValue(m_pHandle, sReturnValueName.c_str(), sReturnValue.c_str())); } + /** + * CUIEnvironment::SetStringResult - Sets a string result value for external event return (typed convenience wrapper). + * @param[in] sReturnValueName - The name of the return parameter. MUST be an alphanumeric ASCII string (with optional _ and -) + * @param[in] sReturnValue - Return value. + */ + void CUIEnvironment::SetStringResult(const std::string & sReturnValueName, const std::string & sReturnValue) + { + CheckError(m_pWrapper->m_WrapperTable.m_UIEnvironment_SetStringResult(m_pHandle, sReturnValueName.c_str(), sReturnValue.c_str())); + } + + /** + * CUIEnvironment::SetIntegerResult - Sets an integer result value for external event return. + * @param[in] sReturnValueName - The name of the return parameter. MUST be an alphanumeric ASCII string (with optional _ and -) + * @param[in] nReturnValue - Return value. + */ + void CUIEnvironment::SetIntegerResult(const std::string & sReturnValueName, const LibMCEnv_int64 nReturnValue) + { + CheckError(m_pWrapper->m_WrapperTable.m_UIEnvironment_SetIntegerResult(m_pHandle, sReturnValueName.c_str(), nReturnValue)); + } + + /** + * CUIEnvironment::SetBoolResult - Sets a boolean result value for external event return. + * @param[in] sReturnValueName - The name of the return parameter. MUST be an alphanumeric ASCII string (with optional _ and -) + * @param[in] bReturnValue - Return value. + */ + void CUIEnvironment::SetBoolResult(const std::string & sReturnValueName, const bool bReturnValue) + { + CheckError(m_pWrapper->m_WrapperTable.m_UIEnvironment_SetBoolResult(m_pHandle, sReturnValueName.c_str(), bReturnValue)); + } + + /** + * CUIEnvironment::SetDoubleResult - Sets a double result value for external event return. + * @param[in] sReturnValueName - The name of the return parameter. MUST be an alphanumeric ASCII string (with optional _ and -) + * @param[in] dReturnValue - Return value. + */ + void CUIEnvironment::SetDoubleResult(const std::string & sReturnValueName, const LibMCEnv_double dReturnValue) + { + CheckError(m_pWrapper->m_WrapperTable.m_UIEnvironment_SetDoubleResult(m_pHandle, sReturnValueName.c_str(), dReturnValue)); + } + /** * CUIEnvironment::GetExternalEventParameters - Returns the external event parameters. This JSON Object was passed on from the external API. * @return Parameter value. diff --git a/Framework/HeadersDev/CppDynamic/libmcenv_types.hpp b/Framework/HeadersDev/CppDynamic/libmcenv_types.hpp index 42e8f6a1..35641291 100644 --- a/Framework/HeadersDev/CppDynamic/libmcenv_types.hpp +++ b/Framework/HeadersDev/CppDynamic/libmcenv_types.hpp @@ -656,6 +656,7 @@ typedef LibMCEnvHandle LibMCEnv_ToolpathLayer; typedef LibMCEnvHandle LibMCEnv_ToolpathAccessor; typedef LibMCEnvHandle LibMCEnv_BuildExecution; typedef LibMCEnvHandle LibMCEnv_BuildExecutionIterator; +typedef LibMCEnvHandle LibMCEnv_BuildIterator; typedef LibMCEnvHandle LibMCEnv_Build; typedef LibMCEnvHandle LibMCEnv_WorkingFileProcess; typedef LibMCEnvHandle LibMCEnv_WorkingFile; diff --git a/Framework/InterfacesCore/libmcenv_abi.hpp b/Framework/InterfacesCore/libmcenv_abi.hpp index 8a342d1f..c9db0bc3 100644 --- a/Framework/InterfacesCore/libmcenv_abi.hpp +++ b/Framework/InterfacesCore/libmcenv_abi.hpp @@ -10987,6 +10987,46 @@ LIBMCENV_DECLSPEC LibMCEnvResult libmcenv_uienvironment_getexternaleventparamete */ LIBMCENV_DECLSPEC LibMCEnvResult libmcenv_uienvironment_addexternaleventresultvalue(LibMCEnv_UIEnvironment pUIEnvironment, const char * pReturnValueName, const char * pReturnValue); +/** +* Sets a string result value for external event return (typed convenience wrapper). +* +* @param[in] pUIEnvironment - UIEnvironment instance. +* @param[in] pReturnValueName - The name of the return parameter. MUST be an alphanumeric ASCII string (with optional _ and -) +* @param[in] pReturnValue - Return value. +* @return error code or 0 (success) +*/ +LIBMCENV_DECLSPEC LibMCEnvResult libmcenv_uienvironment_setstringresult(LibMCEnv_UIEnvironment pUIEnvironment, const char * pReturnValueName, const char * pReturnValue); + +/** +* Sets an integer result value for external event return. +* +* @param[in] pUIEnvironment - UIEnvironment instance. +* @param[in] pReturnValueName - The name of the return parameter. MUST be an alphanumeric ASCII string (with optional _ and -) +* @param[in] nReturnValue - Return value. +* @return error code or 0 (success) +*/ +LIBMCENV_DECLSPEC LibMCEnvResult libmcenv_uienvironment_setintegerresult(LibMCEnv_UIEnvironment pUIEnvironment, const char * pReturnValueName, LibMCEnv_int64 nReturnValue); + +/** +* Sets a boolean result value for external event return. +* +* @param[in] pUIEnvironment - UIEnvironment instance. +* @param[in] pReturnValueName - The name of the return parameter. MUST be an alphanumeric ASCII string (with optional _ and -) +* @param[in] bReturnValue - Return value. +* @return error code or 0 (success) +*/ +LIBMCENV_DECLSPEC LibMCEnvResult libmcenv_uienvironment_setboolresult(LibMCEnv_UIEnvironment pUIEnvironment, const char * pReturnValueName, bool bReturnValue); + +/** +* Sets a double result value for external event return. +* +* @param[in] pUIEnvironment - UIEnvironment instance. +* @param[in] pReturnValueName - The name of the return parameter. MUST be an alphanumeric ASCII string (with optional _ and -) +* @param[in] dReturnValue - Return value. +* @return error code or 0 (success) +*/ +LIBMCENV_DECLSPEC LibMCEnvResult libmcenv_uienvironment_setdoubleresult(LibMCEnv_UIEnvironment pUIEnvironment, const char * pReturnValueName, LibMCEnv_double dReturnValue); + /** * Returns the external event parameters. This JSON Object was passed on from the external API. * diff --git a/Framework/InterfacesCore/libmcenv_interfaces.hpp b/Framework/InterfacesCore/libmcenv_interfaces.hpp index a73ca078..512987f5 100644 --- a/Framework/InterfacesCore/libmcenv_interfaces.hpp +++ b/Framework/InterfacesCore/libmcenv_interfaces.hpp @@ -92,6 +92,7 @@ class IToolpathLayer; class IToolpathAccessor; class IBuildExecution; class IBuildExecutionIterator; +class IBuildIterator; class IBuild; class IWorkingFileProcess; class IWorkingFile; @@ -3517,6 +3518,23 @@ class IBuildExecutionIterator : public virtual IIterator { typedef IBaseSharedPtr PIBuildExecutionIterator; +/************************************************************************************************************************* + Class interface for BuildIterator +**************************************************************************************************************************/ + +class IBuildIterator : public virtual IIterator { +public: + /** + * IBuildIterator::GetCurrentBuild - Returns the build the iterator points at. + * @return returns the Build instance. + */ + virtual IBuild * GetCurrentBuild() = 0; + +}; + +typedef IBaseSharedPtr PIBuildIterator; + + /************************************************************************************************************************* Class interface for Build **************************************************************************************************************************/ @@ -8139,6 +8157,13 @@ class IUIEnvironment : public virtual IBase { */ virtual IBuildExecution * GetBuildExecution(const std::string & sExecutionUUID) = 0; + /** + * IUIEnvironment::GetRecentBuildJobs - Returns an iterator for recent build jobs, ordered by timestamp (newest first). + * @param[in] nMaxCount - Maximum number of jobs to return. Must be greater than 0. + * @return Iterator for build jobs, ordered newest first. + */ + virtual IBuildIterator * GetRecentBuildJobs(const LibMCEnv_uint32 nMaxCount) = 0; + /** * IUIEnvironment::CreateDiscreteField2D - Creates an empty discrete field. * @param[in] nPixelCountX - Pixel count in X. MUST be positive. @@ -8373,6 +8398,34 @@ class IUIEnvironment : public virtual IBase { */ virtual void AddExternalEventResultValue(const std::string & sReturnValueName, const std::string & sReturnValue) = 0; + /** + * IUIEnvironment::SetStringResult - Sets a string result value for external event return (typed convenience wrapper). + * @param[in] sReturnValueName - The name of the return parameter. MUST be an alphanumeric ASCII string (with optional _ and -) + * @param[in] sReturnValue - Return value. + */ + virtual void SetStringResult(const std::string & sReturnValueName, const std::string & sReturnValue) = 0; + + /** + * IUIEnvironment::SetIntegerResult - Sets an integer result value for external event return. + * @param[in] sReturnValueName - The name of the return parameter. MUST be an alphanumeric ASCII string (with optional _ and -) + * @param[in] nReturnValue - Return value. + */ + virtual void SetIntegerResult(const std::string & sReturnValueName, const LibMCEnv_int64 nReturnValue) = 0; + + /** + * IUIEnvironment::SetBoolResult - Sets a boolean result value for external event return. + * @param[in] sReturnValueName - The name of the return parameter. MUST be an alphanumeric ASCII string (with optional _ and -) + * @param[in] bReturnValue - Return value. + */ + virtual void SetBoolResult(const std::string & sReturnValueName, const bool bReturnValue) = 0; + + /** + * IUIEnvironment::SetDoubleResult - Sets a double result value for external event return. + * @param[in] sReturnValueName - The name of the return parameter. MUST be an alphanumeric ASCII string (with optional _ and -) + * @param[in] dReturnValue - Return value. + */ + virtual void SetDoubleResult(const std::string & sReturnValueName, const LibMCEnv_double dReturnValue) = 0; + /** * IUIEnvironment::GetExternalEventParameters - Returns the external event parameters. This JSON Object was passed on from the external API. * @return Parameter value. diff --git a/Framework/InterfacesCore/libmcenv_interfacewrapper.cpp b/Framework/InterfacesCore/libmcenv_interfacewrapper.cpp index 77328a47..033191e2 100644 --- a/Framework/InterfacesCore/libmcenv_interfacewrapper.cpp +++ b/Framework/InterfacesCore/libmcenv_interfacewrapper.cpp @@ -12187,6 +12187,38 @@ LibMCEnvResult libmcenv_buildexecutioniterator_getcurrentexecution(LibMCEnv_Buil } +/************************************************************************************************************************* + Class implementation for BuildIterator +**************************************************************************************************************************/ +LibMCEnvResult libmcenv_builditerator_getcurrentbuild(LibMCEnv_BuildIterator pBuildIterator, LibMCEnv_Build * pBuildInstance) +{ + IBase* pIBaseClass = (IBase *)pBuildIterator; + + try { + if (pBuildInstance == nullptr) + throw ELibMCEnvInterfaceException (LIBMCENV_ERROR_INVALIDPARAM); + IBase* pBaseBuildInstance(nullptr); + IBuildIterator* pIBuildIterator = dynamic_cast(pIBaseClass); + if (!pIBuildIterator) + throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_INVALIDCAST); + + pBaseBuildInstance = pIBuildIterator->GetCurrentBuild(); + + *pBuildInstance = (IBase*)(pBaseBuildInstance); + return LIBMCENV_SUCCESS; + } + catch (ELibMCEnvInterfaceException & Exception) { + return handleLibMCEnvException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + + /************************************************************************************************************************* Class implementation for Build **************************************************************************************************************************/ @@ -32024,6 +32056,34 @@ LibMCEnvResult libmcenv_uienvironment_getbuildexecution(LibMCEnv_UIEnvironment p } } +LibMCEnvResult libmcenv_uienvironment_getrecentbuildjobs(LibMCEnv_UIEnvironment pUIEnvironment, LibMCEnv_uint32 nMaxCount, LibMCEnv_BuildIterator * pBuildIterator) +{ + IBase* pIBaseClass = (IBase *)pUIEnvironment; + + try { + if (pBuildIterator == nullptr) + throw ELibMCEnvInterfaceException (LIBMCENV_ERROR_INVALIDPARAM); + IBase* pBaseBuildIterator(nullptr); + IUIEnvironment* pIUIEnvironment = dynamic_cast(pIBaseClass); + if (!pIUIEnvironment) + throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_INVALIDCAST); + + pBaseBuildIterator = pIUIEnvironment->GetRecentBuildJobs(nMaxCount); + + *pBuildIterator = (IBase*)(pBaseBuildIterator); + return LIBMCENV_SUCCESS; + } + catch (ELibMCEnvInterfaceException & Exception) { + return handleLibMCEnvException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + LibMCEnvResult libmcenv_uienvironment_creatediscretefield2d(LibMCEnv_UIEnvironment pUIEnvironment, LibMCEnv_uint32 nPixelCountX, LibMCEnv_uint32 nPixelCountY, LibMCEnv_double dDPIValueX, LibMCEnv_double dDPIValueY, LibMCEnv_double dOriginX, LibMCEnv_double dOriginY, LibMCEnv_double dDefaultValue, LibMCEnv_DiscreteFieldData2D * pFieldDataInstance) { IBase* pIBaseClass = (IBase *)pUIEnvironment; @@ -33080,6 +33140,117 @@ LibMCEnvResult libmcenv_uienvironment_addexternaleventresultvalue(LibMCEnv_UIEnv } } +LibMCEnvResult libmcenv_uienvironment_setstringresult(LibMCEnv_UIEnvironment pUIEnvironment, const char * pReturnValueName, const char * pReturnValue) +{ + IBase* pIBaseClass = (IBase *)pUIEnvironment; + + try { + if (pReturnValueName == nullptr) + throw ELibMCEnvInterfaceException (LIBMCENV_ERROR_INVALIDPARAM); + if (pReturnValue == nullptr) + throw ELibMCEnvInterfaceException (LIBMCENV_ERROR_INVALIDPARAM); + std::string sReturnValueName(pReturnValueName); + std::string sReturnValue(pReturnValue); + IUIEnvironment* pIUIEnvironment = dynamic_cast(pIBaseClass); + if (!pIUIEnvironment) + throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_INVALIDCAST); + + pIUIEnvironment->SetStringResult(sReturnValueName, sReturnValue); + + return LIBMCENV_SUCCESS; + } + catch (ELibMCEnvInterfaceException & Exception) { + return handleLibMCEnvException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCEnvResult libmcenv_uienvironment_setintegerresult(LibMCEnv_UIEnvironment pUIEnvironment, const char * pReturnValueName, LibMCEnv_int64 nReturnValue) +{ + IBase* pIBaseClass = (IBase *)pUIEnvironment; + + try { + if (pReturnValueName == nullptr) + throw ELibMCEnvInterfaceException (LIBMCENV_ERROR_INVALIDPARAM); + std::string sReturnValueName(pReturnValueName); + IUIEnvironment* pIUIEnvironment = dynamic_cast(pIBaseClass); + if (!pIUIEnvironment) + throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_INVALIDCAST); + + pIUIEnvironment->SetIntegerResult(sReturnValueName, nReturnValue); + + return LIBMCENV_SUCCESS; + } + catch (ELibMCEnvInterfaceException & Exception) { + return handleLibMCEnvException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCEnvResult libmcenv_uienvironment_setboolresult(LibMCEnv_UIEnvironment pUIEnvironment, const char * pReturnValueName, bool bReturnValue) +{ + IBase* pIBaseClass = (IBase *)pUIEnvironment; + + try { + if (pReturnValueName == nullptr) + throw ELibMCEnvInterfaceException (LIBMCENV_ERROR_INVALIDPARAM); + std::string sReturnValueName(pReturnValueName); + IUIEnvironment* pIUIEnvironment = dynamic_cast(pIBaseClass); + if (!pIUIEnvironment) + throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_INVALIDCAST); + + pIUIEnvironment->SetBoolResult(sReturnValueName, bReturnValue); + + return LIBMCENV_SUCCESS; + } + catch (ELibMCEnvInterfaceException & Exception) { + return handleLibMCEnvException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + +LibMCEnvResult libmcenv_uienvironment_setdoubleresult(LibMCEnv_UIEnvironment pUIEnvironment, const char * pReturnValueName, LibMCEnv_double dReturnValue) +{ + IBase* pIBaseClass = (IBase *)pUIEnvironment; + + try { + if (pReturnValueName == nullptr) + throw ELibMCEnvInterfaceException (LIBMCENV_ERROR_INVALIDPARAM); + std::string sReturnValueName(pReturnValueName); + IUIEnvironment* pIUIEnvironment = dynamic_cast(pIBaseClass); + if (!pIUIEnvironment) + throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_INVALIDCAST); + + pIUIEnvironment->SetDoubleResult(sReturnValueName, dReturnValue); + + return LIBMCENV_SUCCESS; + } + catch (ELibMCEnvInterfaceException & Exception) { + return handleLibMCEnvException(pIBaseClass, Exception); + } + catch (std::exception & StdException) { + return handleStdException(pIBaseClass, StdException); + } + catch (...) { + return handleUnhandledException(pIBaseClass); + } +} + LibMCEnvResult libmcenv_uienvironment_getexternaleventparameters(LibMCEnv_UIEnvironment pUIEnvironment, LibMCEnv_JSONObject * pParameterValue) { IBase* pIBaseClass = (IBase *)pUIEnvironment; @@ -33963,6 +34134,8 @@ LibMCEnvResult LibMCEnv::Impl::LibMCEnv_GetProcAddress (const char * pProcName, *ppProcAddress = (void*) &libmcenv_buildexecution_loadattachedjournal; if (sProcName == "libmcenv_buildexecutioniterator_getcurrentexecution") *ppProcAddress = (void*) &libmcenv_buildexecutioniterator_getcurrentexecution; + if (sProcName == "libmcenv_builditerator_getcurrentbuild") + *ppProcAddress = (void*) &libmcenv_builditerator_getcurrentbuild; if (sProcName == "libmcenv_build_getname") *ppProcAddress = (void*) &libmcenv_build_getname; if (sProcName == "libmcenv_build_getbuilduuid") @@ -35153,6 +35326,8 @@ LibMCEnvResult LibMCEnv::Impl::LibMCEnv_GetProcAddress (const char * pProcName, *ppProcAddress = (void*) &libmcenv_uienvironment_hasbuildexecution; if (sProcName == "libmcenv_uienvironment_getbuildexecution") *ppProcAddress = (void*) &libmcenv_uienvironment_getbuildexecution; + if (sProcName == "libmcenv_uienvironment_getrecentbuildjobs") + *ppProcAddress = (void*) &libmcenv_uienvironment_getrecentbuildjobs; if (sProcName == "libmcenv_uienvironment_creatediscretefield2d") *ppProcAddress = (void*) &libmcenv_uienvironment_creatediscretefield2d; if (sProcName == "libmcenv_uienvironment_creatediscretefield2dfromimage") @@ -35217,6 +35392,14 @@ LibMCEnvResult LibMCEnv::Impl::LibMCEnv_GetProcAddress (const char * pProcName, *ppProcAddress = (void*) &libmcenv_uienvironment_getexternaleventparameter; if (sProcName == "libmcenv_uienvironment_addexternaleventresultvalue") *ppProcAddress = (void*) &libmcenv_uienvironment_addexternaleventresultvalue; + if (sProcName == "libmcenv_uienvironment_setstringresult") + *ppProcAddress = (void*) &libmcenv_uienvironment_setstringresult; + if (sProcName == "libmcenv_uienvironment_setintegerresult") + *ppProcAddress = (void*) &libmcenv_uienvironment_setintegerresult; + if (sProcName == "libmcenv_uienvironment_setboolresult") + *ppProcAddress = (void*) &libmcenv_uienvironment_setboolresult; + if (sProcName == "libmcenv_uienvironment_setdoubleresult") + *ppProcAddress = (void*) &libmcenv_uienvironment_setdoubleresult; if (sProcName == "libmcenv_uienvironment_getexternaleventparameters") *ppProcAddress = (void*) &libmcenv_uienvironment_getexternaleventparameters; if (sProcName == "libmcenv_uienvironment_getexternaleventresults") diff --git a/Framework/InterfacesCore/libmcenv_types.hpp b/Framework/InterfacesCore/libmcenv_types.hpp index 42e8f6a1..35641291 100644 --- a/Framework/InterfacesCore/libmcenv_types.hpp +++ b/Framework/InterfacesCore/libmcenv_types.hpp @@ -656,6 +656,7 @@ typedef LibMCEnvHandle LibMCEnv_ToolpathLayer; typedef LibMCEnvHandle LibMCEnv_ToolpathAccessor; typedef LibMCEnvHandle LibMCEnv_BuildExecution; typedef LibMCEnvHandle LibMCEnv_BuildExecutionIterator; +typedef LibMCEnvHandle LibMCEnv_BuildIterator; typedef LibMCEnvHandle LibMCEnv_Build; typedef LibMCEnvHandle LibMCEnv_WorkingFileProcess; typedef LibMCEnvHandle LibMCEnv_WorkingFile; diff --git a/Implementation/LibMCEnv/libmcenv_build.cpp b/Implementation/LibMCEnv/libmcenv_build.cpp index d3836a86..2cdab0a6 100644 --- a/Implementation/LibMCEnv/libmcenv_build.cpp +++ b/Implementation/LibMCEnv/libmcenv_build.cpp @@ -81,6 +81,19 @@ CBuild::~CBuild() { } +CBuild* CBuild::makeFrom(CBuild* pBuild) +{ + if (pBuild == nullptr) + throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_INVALIDPARAM); + + return new CBuild(pBuild->m_pDataModel, pBuild->m_sBuildJobUUID, pBuild->m_pToolpathHandler, pBuild->m_pMeshHandler, pBuild->m_pGlobalChrono, pBuild->m_pStateJournal); +} + +std::shared_ptr CBuild::makeSharedFrom(CBuild* pBuild) +{ + return std::shared_ptr(makeFrom(pBuild)); +} + std::string CBuild::GetName() { auto pBuildJobHandler = m_pDataModel->CreateBuildJobHandler(); diff --git a/Implementation/LibMCEnv/libmcenv_build.hpp b/Implementation/LibMCEnv/libmcenv_build.hpp index bdae825f..f793b02d 100644 --- a/Implementation/LibMCEnv/libmcenv_build.hpp +++ b/Implementation/LibMCEnv/libmcenv_build.hpp @@ -73,6 +73,10 @@ class CBuild : public virtual IBuild, public virtual CBase { virtual ~CBuild(); + static CBuild* makeFrom (CBuild * pBuild); + + static std::shared_ptr makeSharedFrom(CBuild* pBuild); + std::string GetName() override; std::string GetBuildUUID() override; diff --git a/Implementation/LibMCEnv/libmcenv_builditerator.cpp b/Implementation/LibMCEnv/libmcenv_builditerator.cpp new file mode 100644 index 00000000..0250eaf7 --- /dev/null +++ b/Implementation/LibMCEnv/libmcenv_builditerator.cpp @@ -0,0 +1,97 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is a stub class definition of CBuildIterator + +*/ + +#include "libmcenv_builditerator.hpp" +#include "libmcenv_interfaceexception.hpp" + +// Include custom headers here. + + +using namespace LibMCEnv::Impl; + +/************************************************************************************************************************* + Class definition of CBuildIterator +**************************************************************************************************************************/ + +CBuildIterator::CBuildIterator() +{ + +} + +CBuildIterator::~CBuildIterator() +{ + +} + + +IBase* CBuildIterator::GetCurrent() +{ + return GetCurrentBuild(); +} + +IBuild* CBuildIterator::GetCurrentBuild() +{ + if ((m_nCurrentIndex < 0) || (m_nCurrentIndex >= m_List.size())) + throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_INVALIDITERATOR); + + auto pBuild = std::dynamic_pointer_cast (m_List[m_nCurrentIndex]); + if (pBuild.get() == nullptr) + throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_INVALIDCAST); + + return CBuild::makeFrom(pBuild.get()); +} + + +IIterator* CBuildIterator::Clone() +{ + std::unique_ptr pNewIterator(new CBuildIterator()); + + for (auto pBase : m_List) { + auto pBuild = std::dynamic_pointer_cast (pBase); + if (pBuild.get() == nullptr) + throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_INVALIDCAST); + pNewIterator->AddBuild(CBuild::makeSharedFrom(pBuild.get())); + } + + return pNewIterator.release(); +} + +void CBuildIterator::AddBuild(std::shared_ptr pBuild) +{ + if (pBuild.get() == nullptr) + throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_INVALIDPARAM); + + m_List.push_back(pBuild); +} + + diff --git a/Implementation/LibMCEnv/libmcenv_builditerator.hpp b/Implementation/LibMCEnv/libmcenv_builditerator.hpp new file mode 100644 index 00000000..a2d8aa90 --- /dev/null +++ b/Implementation/LibMCEnv/libmcenv_builditerator.hpp @@ -0,0 +1,82 @@ +/*++ + +Copyright (C) 2020 Autodesk Inc. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Autodesk Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Abstract: This is the class declaration of CBuildIterator + +*/ + + +#ifndef __LIBMCENV_BUILDITERATOR +#define __LIBMCENV_BUILDITERATOR + +#include "libmcenv_interfaces.hpp" + +// Parent classes +#include "libmcenv_iterator.hpp" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4250) +#endif + +// Include custom headers here. +#include "libmcenv_build.hpp" + + +namespace LibMCEnv { +namespace Impl { + + +/************************************************************************************************************************* + Class declaration of CBuildIterator +**************************************************************************************************************************/ + +class CBuildIterator : public virtual IBuildIterator, public virtual CIterator { + +public: + CBuildIterator(); + + virtual ~CBuildIterator(); + + IIterator* Clone() override; + + IBase* GetCurrent() override; + + IBuild* GetCurrentBuild() override; + + void AddBuild(std::shared_ptr pBuild); + +}; + +} // namespace Impl +} // namespace LibMCEnv + +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#endif // __LIBMCENV_BUILDITERATOR diff --git a/Implementation/LibMCEnv/libmcenv_uienvironment.cpp b/Implementation/LibMCEnv/libmcenv_uienvironment.cpp index afc93668..739d1626 100644 --- a/Implementation/LibMCEnv/libmcenv_uienvironment.cpp +++ b/Implementation/LibMCEnv/libmcenv_uienvironment.cpp @@ -60,6 +60,7 @@ Abstract: This is a stub class definition of CUIEnvironment #include "libmcenv_imagedata.hpp" #include "libmcenv_testenvironment.hpp" #include "libmcenv_build.hpp" +#include "libmcenv_builditerator.hpp" #include "libmcenv_buildexecution.hpp" #include "libmcenv_streamreader.hpp" #include "libmcenv_datatable.hpp" @@ -617,6 +618,32 @@ IBuildExecution* CUIEnvironment::GetBuildExecution(const std::string& sExecution } +IBuildIterator* CUIEnvironment::GetRecentBuildJobs(const LibMCEnv_uint32 nMaxCount) +{ + if (nMaxCount == 0) + throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_INVALIDPARAM, "MaxCount must be greater than 0"); + + auto pDataModel = m_pUISystemState->getDataModel(); + auto pBuildJobHandler = pDataModel->CreateBuildJobHandler(); + auto pBuildJobIterator = pBuildJobHandler->ListJobsByStatus(LibMCData::eBuildJobStatus::Validated); + + std::unique_ptr pResultIterator(new CBuildIterator()); + + uint32_t nCount = 0; + while (pBuildJobIterator->MoveNext() && (nCount < nMaxCount)) { + auto pBuildJob = pBuildJobIterator->GetCurrentJob(); + auto pBuild = std::make_shared(pDataModel, pBuildJob->GetUUID(), + m_pUISystemState->getToolpathHandler(), + m_pUISystemState->getMeshHandler(), + m_pUISystemState->getGlobalChronoInstance(), + m_pUISystemState->getStateJournal()); + pResultIterator->AddBuild(pBuild); + nCount++; + } + + return pResultIterator.release(); +} + IDiscreteFieldData2D* CUIEnvironment::CreateDiscreteField2D(const LibMCEnv_uint32 nPixelSizeX, const LibMCEnv_uint32 nPixelSizeY, const LibMCEnv_double dDPIValueX, const LibMCEnv_double dDPIValueY, const LibMCEnv_double dOriginX, const LibMCEnv_double dOriginY, const LibMCEnv_double dDefaultValue) { @@ -1024,6 +1051,69 @@ void CUIEnvironment::AddExternalEventResultValue(const std::string& sReturnValue m_ExternalEventReturnValues->AddMember(jsonName, jsonValue, m_ExternalEventReturnValues->GetAllocator ()); } +void CUIEnvironment::SetStringResult(const std::string& sReturnValueName, const std::string& sReturnValue) +{ + // Convenience wrapper for AddExternalEventResultValue + AddExternalEventResultValue(sReturnValueName, sReturnValue); +} + +void CUIEnvironment::SetIntegerResult(const std::string& sReturnValueName, const LibMCEnv_int64 nReturnValue) +{ + if (!AMCCommon::CUtils::stringIsValidAlphanumericNameString(sReturnValueName)) + throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_INVALIDEXTERNALEVENTRETURNVALUEKEY, "invalid external return value key: " + sReturnValueName); + + if (AMC::CUIHandleEventResponse::externalValueNameIsReserved(sReturnValueName)) + throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_EXTERNALEVENTRETURNVALUEKEYISRESERVED, "external return value key is reserved: " + sReturnValueName); + + if (m_ExternalEventReturnValues->HasMember(sReturnValueName.c_str())) + throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_DUPLICATEEXTERNALEVENTRETURNKEY, "duplicate external event return key: " + sReturnValueName); + + rapidjson::Value jsonName; + rapidjson::Value jsonValue; + + jsonName.SetString(sReturnValueName.c_str(), m_ExternalEventReturnValues->GetAllocator()); + jsonValue.SetInt64(nReturnValue); + m_ExternalEventReturnValues->AddMember(jsonName, jsonValue, m_ExternalEventReturnValues->GetAllocator()); +} + +void CUIEnvironment::SetBoolResult(const std::string& sReturnValueName, const bool bReturnValue) +{ + if (!AMCCommon::CUtils::stringIsValidAlphanumericNameString(sReturnValueName)) + throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_INVALIDEXTERNALEVENTRETURNVALUEKEY, "invalid external return value key: " + sReturnValueName); + + if (AMC::CUIHandleEventResponse::externalValueNameIsReserved(sReturnValueName)) + throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_EXTERNALEVENTRETURNVALUEKEYISRESERVED, "external return value key is reserved: " + sReturnValueName); + + if (m_ExternalEventReturnValues->HasMember(sReturnValueName.c_str())) + throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_DUPLICATEEXTERNALEVENTRETURNKEY, "duplicate external event return key: " + sReturnValueName); + + rapidjson::Value jsonName; + rapidjson::Value jsonValue; + + jsonName.SetString(sReturnValueName.c_str(), m_ExternalEventReturnValues->GetAllocator()); + jsonValue.SetBool(bReturnValue); + m_ExternalEventReturnValues->AddMember(jsonName, jsonValue, m_ExternalEventReturnValues->GetAllocator()); +} + +void CUIEnvironment::SetDoubleResult(const std::string& sReturnValueName, const LibMCEnv_double dReturnValue) +{ + if (!AMCCommon::CUtils::stringIsValidAlphanumericNameString(sReturnValueName)) + throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_INVALIDEXTERNALEVENTRETURNVALUEKEY, "invalid external return value key: " + sReturnValueName); + + if (AMC::CUIHandleEventResponse::externalValueNameIsReserved(sReturnValueName)) + throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_EXTERNALEVENTRETURNVALUEKEYISRESERVED, "external return value key is reserved: " + sReturnValueName); + + if (m_ExternalEventReturnValues->HasMember(sReturnValueName.c_str())) + throw ELibMCEnvInterfaceException(LIBMCENV_ERROR_DUPLICATEEXTERNALEVENTRETURNKEY, "duplicate external event return key: " + sReturnValueName); + + rapidjson::Value jsonName; + rapidjson::Value jsonValue; + + jsonName.SetString(sReturnValueName.c_str(), m_ExternalEventReturnValues->GetAllocator()); + jsonValue.SetDouble(dReturnValue); + m_ExternalEventReturnValues->AddMember(jsonName, jsonValue, m_ExternalEventReturnValues->GetAllocator()); +} + IJSONObject* CUIEnvironment::GetExternalEventParameters() { return new CJSONObject(m_ExternalEventParameters, m_ExternalEventParameters.get()); diff --git a/Implementation/LibMCEnv/libmcenv_uienvironment.hpp b/Implementation/LibMCEnv/libmcenv_uienvironment.hpp index 10f409de..9ba33b23 100644 --- a/Implementation/LibMCEnv/libmcenv_uienvironment.hpp +++ b/Implementation/LibMCEnv/libmcenv_uienvironment.hpp @@ -198,6 +198,8 @@ class CUIEnvironment : public virtual IUIEnvironment, public virtual CBase { IBuildExecution* GetBuildExecution(const std::string& sExecutionUUID) override; + IBuildIterator* GetRecentBuildJobs(const LibMCEnv_uint32 nMaxCount) override; + IDiscreteFieldData2D* CreateDiscreteField2D(const LibMCEnv_uint32 nPixelSizeX, const LibMCEnv_uint32 nPixelSizeY, const LibMCEnv_double dDPIValueX, const LibMCEnv_double dDPIValueY, const LibMCEnv_double dOriginX, const LibMCEnv_double dOriginY, const LibMCEnv_double dDefaultValue) override; IDiscreteFieldData2D* CreateDiscreteField2DFromImage(IImageData* pImageDataInstance, const LibMCEnv_double dBlackValue, const LibMCEnv_double dWhiteValue, const LibMCEnv_double dOriginX, const LibMCEnv_double dOriginY) override; @@ -268,6 +270,15 @@ class CUIEnvironment : public virtual IUIEnvironment, public virtual CBase { void AddExternalEventResultValue(const std::string& sReturnValueName, const std::string& sReturnValue) override; + // Typed result setters for /api/ext event handlers + void SetStringResult(const std::string& sReturnValueName, const std::string& sReturnValue) override; + + void SetIntegerResult(const std::string& sReturnValueName, const LibMCEnv_int64 nReturnValue) override; + + void SetBoolResult(const std::string& sReturnValueName, const bool bReturnValue) override; + + void SetDoubleResult(const std::string& sReturnValueName, const LibMCEnv_double dReturnValue) override; + IJSONObject* GetExternalEventParameters() override; IJSONObject* GetExternalEventResults() override;