From 96952c35f8beea515a1e4abbb2db80a32565a671 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 26 May 2015 06:52:11 +0000 Subject: [PATCH] Include : - aggiornamento prototipi - aggiunte per ObjUser. --- EGkGeomDB.h | 7 ++++ EGkObjUser.h | 32 +++++++++++++++++ EGkObjUserFactory.h | 75 +++++++++++++++++++++++++++++++++++++++ EGnStringKeyVal.h | 85 +++++++++++++++++++++++++++++++++++++++++++++ EGnStringUtils.h | 2 +- EMkMachMgr.h | 4 ++- EXeExecutor.h | 3 +- 7 files changed, 205 insertions(+), 3 deletions(-) create mode 100644 EGkObjUser.h create mode 100644 EGkObjUserFactory.h create mode 100644 EGnStringKeyVal.h diff --git a/EGkGeomDB.h b/EGkGeomDB.h index ea39354..c392f3a 100644 --- a/EGkGeomDB.h +++ b/EGkGeomDB.h @@ -20,6 +20,7 @@ #include "/EgtDev/Include/EGkGeoFrame3d.h" #include "/EgtDev/Include/EGkGeoObj.h" #include "/EgtDev/Include/EGkMaterial.h" +#include "/EgtDev/Include/EGkObjUser.h" #include "/EgtDev/Include/EgtNumCollection.h" #include "/EgtDev/Include/EgtStringBase.h" #include "/EgtDev/Include/EgtILogger.h" @@ -169,6 +170,12 @@ class __declspec( novtable) IGeomDB virtual bool GetInfo( int nId, const std::string& sKey, STRVECTOR& vsInfo) const = 0 ; virtual bool ExistsInfo( int nId, const std::string& sKey) const = 0 ; virtual bool RemoveInfo( int nId, const std::string& sKey) = 0 ; + // ObjUser + virtual bool SetObjUser( int nId, IObjUser* pObjUser) = 0 ; + virtual IObjUser* GetObjUser( int nId) = 0 ; + virtual const IObjUser* GetObjUser( int nId) const = 0 ; + virtual bool DumpObjUser( int nId, std::string& sOut, const char* szNewLine) const = 0 ; + virtual bool CopyObjUser( int nIdSou, int nIdDest) = 0 ; // Material library virtual int AddMaterial( const std::string& sName, const Material& matM) = 0 ; virtual int FindMaterial( const std::string& sName) const = 0 ; diff --git a/EGkObjUser.h b/EGkObjUser.h new file mode 100644 index 0000000..27ed572 --- /dev/null +++ b/EGkObjUser.h @@ -0,0 +1,32 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : EGkObjUser.h Data : 22.05.15 Versione : 1.6e3 +// Contenuto : Dichiarazione della interfaccia IObjUser. +// +// +// +// Modifiche : 22.05.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "/EgtDev/Include/EgtStringBase.h" + +//---------------------------------------------------------------------------- +class __declspec( novtable) IObjUser +{ + public : + virtual ~IObjUser( void) {} + virtual IObjUser* Clone( void) const = 0 ; + virtual bool IsDefault(void) const { return false ; } + virtual const std::string& GetClassName( void) const = 0 ; + virtual bool Dump( std::string& sOut, const char* szNewLine = "\n") const = 0 ; + virtual bool ToSave( void) const { return false ; } + virtual bool Save( STRVECTOR& vString) const { return false ; } + virtual bool Load( const STRVECTOR& vString) { return false ; } + virtual bool SetOwner( int nId) = 0 ; + virtual int GetOwner( void) const = 0 ; +} ; diff --git a/EGkObjUserFactory.h b/EGkObjUserFactory.h new file mode 100644 index 0000000..7cb7015 --- /dev/null +++ b/EGkObjUserFactory.h @@ -0,0 +1,75 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : EGkObjUserFactory.h Data : 22.05.15 Versione : 1.6e3 +// Contenuto : Factory della classe IObjUser. +// +// +// +// Modifiche : 22.05.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "/EgtDev/Include/EGkObjUser.h" +#include +#include + +//----------------------- Macro per import/export ---------------------------- +#undef EGK_EXPORT +#if defined( I_AM_EGK) // da definirsi solo nella DLL + #define EGK_EXPORT __declspec( dllexport) +#else + #define EGK_EXPORT __declspec( dllimport) +#endif + +//---------------------------------------------------------------------------- +#define OBJUSER_REGISTER( sName, T) static const bool bReg_##T = \ + ObjUserRegister::DoRegister( sName) +#define OBJUSER_GETNAME( T) ObjUserRegister::GetName() +#define OBJUSER_CREATE( sName) ObjUserFactory::Create( sName) + +//---------------------------------------------------------------------------- +template +class ObjUserRegister +{ + public : + static bool DoRegister( const std::string& sName) + { if ( ! ObjUserFactory::Register( sName, Create)) + return false ; + GetNamePrivate() = sName ; + return true ; } + static IObjUser* Create( void) + { return new(nothrow) T ; } + static const std::string& GetName( void) + { return GetNamePrivate() ; } + + private : + ObjUserRegister( void) {} + ~ObjUserRegister( void) {} + static std::string& GetNamePrivate( void) + { static std::string s_sName ; + return s_sName ; } +} ; + +//---------------------------------------------------------------------------- +class ObjUserFactory +{ + public : + // definizione del tipo funzione di creazione + typedef IObjUser* ( *ObjUserCreator) ( void) ; + // per registrare le funzioni di creazione + EGK_EXPORT static bool Register( const std::string& sName, ObjUserCreator Creator) ; + // per creare l'oggetto richiesto + EGK_EXPORT static IObjUser* Create( const std::string& sName) ; + + private : + ObjUserFactory( void) {} + ~ObjUserFactory( void) {} + // definizione del tipo mappa con coppie nome, funzione di creazione + typedef std::unordered_map CreatorMap ; + // metodo di accesso alla mappa statica + static CreatorMap& GetCreatorMap( void) ; +} ; diff --git a/EGnStringKeyVal.h b/EGnStringKeyVal.h new file mode 100644 index 0000000..104094a --- /dev/null +++ b/EGnStringKeyVal.h @@ -0,0 +1,85 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : EgnStringKeyVal.h Data : 23.05.15 Versione : 1.6e3 +// Contenuto : Funzioni per gestione coppie chiave-valore in stringhe. +// +// +// +// Modifiche : 23.05.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "/EgtDev/Include/EgnStringUtils.h" + +//---------------------------------------------------------------------------- +static const char EQUAL = '=' ; + +//---------------------------------------------------------------------------- +inline bool +FindKey( const std::string& sString, const std::string& sKey) +{ + return ( sString.compare( 0, sKey.length(), sKey) == 0 && + sString.length() > sKey.length() && + sString[sKey.length()] == EQUAL) ; +} + +//---------------------------------------------------------------------------- +inline bool +IsValidKey( const std::string& sString) +{ + return ( ! sString.empty() && + sString.find( '\n') == std::string::npos && + sString.find_first_not_of( " \t\r\n") != std::string::npos) ; +} + +//---------------------------------------------------------------------------- +inline bool +IsValidVal( const std::string& sString) +{ + return ( sString.empty() || + ( sString.find( '\n') == std::string::npos && + sString.find_first_not_of( " \t\r\n") != std::string::npos)) ; +} + +//---------------------------------------------------------------------------- +inline bool +SetVal( const std::string& sKey, const std::string& sVal, std::string& sString) +{ + if ( ! IsValidKey( sKey) || ! IsValidVal( sVal)) + return false ; + sString = sKey + EQUAL + sVal ; + return true ; +} + +//---------------------------------------------------------------------------- +template +inline bool +SetVal( const std::string& sKey, T& Val, std::string& sString) +{ + return SetVal( sKey, ToString( Val), sString) ; +} + +//---------------------------------------------------------------------------- +inline bool +GetVal( const std::string& sString, const std::string& sKey, std::string& sVal) +{ + if ( ! IsValidKey( sKey)) + return false ; + if ( ! FindKey( sString, sKey)) + return false ; + sVal = sString.substr( sKey.length() + 1) ; + return true ; +} + +//---------------------------------------------------------------------------- +template +inline bool +GetVal( const std::string& sString, const std::string& sKey, T& Val) +{ + std::string sVal ; + return ( GetVal( sString, sKey, sVal) && FromString( sVal, Val)) ; +} diff --git a/EGnStringUtils.h b/EGnStringUtils.h index cc48646..0b817c4 100644 --- a/EGnStringUtils.h +++ b/EGnStringUtils.h @@ -61,7 +61,7 @@ ToLower( std::string& sString) { std::transform( sString.begin(), sString.end(), sString.begin(), ::tolower) ; return sString ; } inline bool -CompareNoCase( const std::string& sL, const std::string& sR) +EqualNoCase( const std::string& sL, const std::string& sR) { return ( sL.size() == sR.size() && std::equal( sL.cbegin(), sL.cend(), sR.cbegin(), []( std::string::value_type cL, std::string::value_type cR) diff --git a/EMkMachMgr.h b/EMkMachMgr.h index 3c281df..335bdcc 100644 --- a/EMkMachMgr.h +++ b/EMkMachMgr.h @@ -76,11 +76,13 @@ class __declspec( novtable) IMachMgr virtual bool ResetHeadSet( const std::string& sHead) = 0 ; virtual bool SetCalcTable( const std::string& sTable) = 0 ; virtual bool SetCalcTool( const std::string& sTool, const std::string& sHead, int nExit) = 0 ; - virtual bool GetCalcAngles( const Vector3d& vtDirT, + virtual bool GetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) = 0 ; virtual bool GetCalcPositions( const Point3d& ptP, double dAngA, double dAngB, int& nStat, double& dX, double& dY, double& dZ) = 0 ; virtual bool VerifyOutOfStroke( double dX, double dY, double dZ, double dAngA, double dAngB, int& nStat) = 0 ; + // Operations + virtual int AddDrilling( const std::string& sName) = 0 ; } ; diff --git a/EXeExecutor.h b/EXeExecutor.h index 9f407af..c72df3a 100644 --- a/EXeExecutor.h +++ b/EXeExecutor.h @@ -423,11 +423,12 @@ EXE_EXPORT bool ExeLoadTool( const std::string& sHead, int nExit, const std::str EXE_EXPORT bool ExeResetHeadSet( const std::string& sHead) ; EXE_EXPORT bool ExeSetCalcTable( const std::string& sTable) ; EXE_EXPORT bool ExeSetCalcTool( const std::string& sTool, const std::string& sHead, int nExit) ; -EXE_EXPORT bool ExeGetCalcAngles( const Vector3d& vtDirT, +EXE_EXPORT bool ExeGetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) ; EXE_EXPORT bool ExeGetCalcPositions( const Point3d& ptP, double dAngA, double dAngB, int& nStat, double& dX, double& dY, double& dZ) ; EXE_EXPORT bool ExeVerifyOutOfStroke( double dX, double dY, double dZ, double dAngA, double dAngB, int& nStat) ; +EXE_EXPORT int ExeAddDrilling( const std::string& sName) ; // Scene EXE_EXPORT bool ExeInitScene( HWND hWnd, int nDriver, bool b2Buff, int nColorBits, int nDepthBits) ;