All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GCUtilities.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // (c) 2005 by Basler Vision Technologies
3 // Section: Vision Components
4 // Project: GenICam
5 // Author: Fritz Dierks
6 // $Header$
7 // License: This file is published under the license of the EMVA GenICam Standard Group.
8 // A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'.
9 // If for some reason you are missing this file please contact the EMVA or visit the website
10 // (http://www.genicam.org) for a full copy.
11 //
12 // THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS"
13 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
14 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP
16 // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
17 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
18 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
19 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
20 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
22 // POSSIBILITY OF SUCH DAMAGE.
23 //-----------------------------------------------------------------------------
30 #ifndef GENAPI_GENAPIUTILITIES_DEF_H_
31 #define GENAPI_GENAPIUTILITIES_DEF_H_
32 
33 #if defined (_WIN32)
34 # include <windows.h>
35 #endif
36 
37 #include <GenICamVersion.h>
38 
39 #include <Base/GCTypes.h>
40 #include <Base/GCString.h>
41 #include <Base/GCStringVector.h>
42 #include <Base/GCException.h>
43 #include <Base/GCLinkage.h>
44 
45 #if defined(UNDER_RTSS)
46 #include <Base/GCRTSSUtilities.h>
47 #endif // defined(UNDER_RTSS)
48 
49 #if defined(UNDER_RTSS)
50 #define USE_TEMP_CACHE_FILE 0
51 #else
52 #define USE_TEMP_CACHE_FILE 1
53 #endif // defined(UNDER_RTSS)
54 
55 #if defined(UNDER_RTSS)
56 #define USE_TEMP_CACHE_FILE 0
57 #else
58 #define USE_TEMP_CACHE_FILE 1
59 #endif // defined(UNDER_RTSS)
60 
61 #if defined (_MSC_VER)
62 # if defined (_WIN64)
63 # define PLATFORM_NAME "Win64_x64"
64 # else
65 # define PLATFORM_NAME "Win32_i86"
66 # endif
67 #elif defined (__GNUC__)
68 # define GENICAM_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
69 # if defined (__LP64__)
70 # if defined (__linux__)
71 # define PLATFORM_NAME "Linux64_x64"
72 # elif defined (__APPLE__)
73 # define PLATFORM_NAME "Maci64_x64"
74 # else
75 # error Unknown Platform
76 # endif
77 # else
78 # if defined (__linux__)
79 # define PLATFORM_NAME "Linux32_i86"
80 # elif defined (__APPLE__)
81 # error Unsupported Platform
82 # elif defined (VXWORKS)
83 # define PLATFORM_NAME "VxWorks_PPC"
84 # else
85 # error Unknown Platform
86 # endif
87 # endif
88 #else
89 # error Unknown Platform
90 #endif
91 
92 #ifndef GC_COUNTOF
93 # define GC_COUNTOF(arr) (sizeof (arr) / sizeof (arr)[0] )
94 #endif
95 
96 namespace GENICAM_NAMESPACE
97 {
100  template<typename Td, typename Ts>
101  inline Td INTEGRAL_CAST2( Ts s )
102  {
103  const Td d = static_cast<Td>( s );
104  if ( static_cast<Ts>( d ) != s ){
105  throw RUNTIME_EXCEPTION("INTEGRAL_CAST failed");
106  }
107  return d;
108  }
109 
112  template<typename T>
113  inline T INTEGRAL_CAST( int64_t ll )
114  {
115  return INTEGRAL_CAST2<T, int64_t>( ll );
116  }
117 
119  GCBASE_API bool GetCacheFileDirectory(gcstring &CacheFileDirectory);
120 
122  GCBASE_API bool HasValidLength(const gcstring &FileName);
123 
125  GCBASE_API bool HasValidExtension(const gcstring &FileName);
126 
127  // Returns the cache file names in the given cache directory
128  GCBASE_API void GetCandidateCacheFilePaths(gcstring_vector &CacheFileNames, const gcstring &CacheFileDirectory); //
129 
130  // Returns the message that corresponds to the last error
131  GCBASE_API void GetLastErrorMessage(gcstring &Message);
132 
134  GCBASE_API bool DoesEnvironmentVariableExist( const gcstring &VariableName );
135 
138  GCBASE_API gcstring GetValueOfEnvironmentVariable( const gcstring &VariableName );
139 
142  GCBASE_API bool GetValueOfEnvironmentVariable(const gcstring &VariableName, gcstring &VariableContent );
143 
144 #if defined(UNDER_RTSS)
145  GCBASE_API bool DoesFileExist( const gcstring &FilePath );
147 #endif // defined(UNDER_RTSS)
148 
151  GCBASE_API gcstring UrlEncode(const GENICAM_NAMESPACE::gcstring& Input);
152 
156 
159  GCBASE_API void ReplaceEnvironmentVariables(gcstring &Buffer, bool ReplaceBlankBy20 = false);
160 
161 
163 
168  GCBASE_API gcstring GetGenICamCacheFolder(void);
169 
171 
176  GCBASE_API gcstring GetGenICamLogConfig(void);
177 
179 
184  GCBASE_API gcstring GetGenICamCLProtocolFolder(void);
185 
187  GCBASE_API void SetGenICamCacheFolder(const gcstring& path);
188 
190  GCBASE_API void SetGenICamLogConfig(const gcstring& path);
191 
193  GCBASE_API void SetGenICamCLProtocolFolder(const gcstring& path);
194 
196  GCBASE_API void Tokenize(
197  const gcstring& str,
198  gcstring_vector& tokens,
199  const gcstring& delimiters = " "
200  );
201 
203  GCBASE_API void GetFiles(
204  const gcstring &FileTemplate,
205  gcstring_vector &FileNames,
206  const bool DirectoriesOnly = false );
207 
209  GCBASE_API gcstring GetModulePathFromFunction(void *pFunction);
210 }
211 
212 #define GENICAM_UNUSED(unused_var) ((void)(unused_var))
213 
214 #if !defined(GENICAM_DEPRECATED)
215 # if defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__ ) >= 301) // is at least GCC 3.1 compiler?
216 # define GENICAM_DEPRECATED(FUNCTION) FUNCTION __attribute__ ((deprecated))
217 # elif defined(_MSC_VER) && (_MSC_VER >= 1300) // is at least VC 2003 compiler?
218 # define GENICAM_DEPRECATED(FUNCTION) __declspec(deprecated) FUNCTION
219 # else
220 # define GENICAM_DEPRECATED(FUNCTION) FUNCTION
221 # endif // compiler check
222 #endif // #if !defined(GENICAM_DEPRECATED)
223 
224 
226 //
227 // Useful to create pragma message output recognized by VisualStudio
228 //
229 // Usage:
230 // #pragma message ( __ERR__ "Invalid DLL ABI" )
231 //
233 // Message formatter
234 #define _TO_STRING( __stN ) #__stN
235 #define EXPAND_TO_STRINGISE( __stN ) _TO_STRING( __stN )
236 #define __LINE_STR__ EXPAND_TO_STRINGISE(__LINE__)
237 #define __LOCATION__ __FILE__ "(" __LINE_STR__ ")"
238 #define __OUTPUT_FORMATER__(_type) __LOCATION__ " : " _type " : "
239 
240 // Message types
241 #define __WARN__ __OUTPUT_FORMATER__("WARNING")
242 #define __ERR__ __OUTPUT_FORMATER__("ERROR")
243 #define __TODO__ __OUTPUT_FORMATER__("TBD")
244 
245 #endif // GENAPI_GENAPIUTILITIES_DEF_H_
GCLinkage.h
helpers for pragma linkage
GENICAM_NAMESPACE::INTEGRAL_CAST
T INTEGRAL_CAST(int64_t ll)
This verifies at runtime if there was no loss of data if an int64_t was downcast to type T (e....
Definition: GCUtilities.h:113
GENICAM_NAMESPACE::INTEGRAL_CAST2
Td INTEGRAL_CAST2(Ts s)
This verifies at runtime if there was no loss of data if an type Ts (e.g. int64t) was downcast to typ...
Definition: GCUtilities.h:101
GENICAM_NAMESPACE
Definition: GCArray.h:32
GENICAM_NAMESPACE::GetLastErrorMessage
GCBASE_API void GetLastErrorMessage(gcstring &Message)
GENICAM_NAMESPACE::gcstring
A string class which is a clone of std::string.
Definition: GCString.h:52
GCStringVector.h
Portable string vector implementation.
GENICAM_NAMESPACE::Tokenize
GCBASE_API void Tokenize(const gcstring &str, gcstring_vector &tokens, const gcstring &delimiters=" ")
splits str input string into a list of tokens using the delimiter
GenICamVersion.h
central versioning counters
GENICAM_NAMESPACE::UrlEncode
GCBASE_API gcstring UrlEncode(const GENICAM_NAMESPACE::gcstring &Input)
Converts \ to / and replaces all unsafe characters by their xx equivalent.
GENICAM_NAMESPACE::SetGenICamCacheFolder
GCBASE_API void SetGenICamCacheFolder(const gcstring &path)
Stores the path of the GenICam cache folder.
GENICAM_NAMESPACE::GetGenICamLogConfig
GCBASE_API gcstring GetGenICamLogConfig(void)
Retrieve the path of the GenICam logging properties file.
GCRTSSUtilities.h
GenICam RTSS utilities.
GENICAM_NAMESPACE::GetValueOfEnvironmentVariable
GCBASE_API gcstring GetValueOfEnvironmentVariable(const gcstring &VariableName)
Retrieve the value of an environment variable.
GENICAM_NAMESPACE::SetGenICamCLProtocolFolder
GCBASE_API void SetGenICamCLProtocolFolder(const gcstring &path)
Stores the path of the CLProtocol folder.
GENICAM_NAMESPACE::GetGenICamCacheFolder
GCBASE_API gcstring GetGenICamCacheFolder(void)
Retrieve the path of the GenICam cache folder.
GENICAM_NAMESPACE::UrlDecode
GCBASE_API GENICAM_NAMESPACE::gcstring UrlDecode(const GENICAM_NAMESPACE::gcstring &Input)
Replaces xx escapes by their char equivalent.
GENICAM_NAMESPACE::HasValidLength
GCBASE_API bool HasValidLength(const gcstring &FileName)
Returns the truth value for the proposition: The given file name has the valid length.
GENICAM_NAMESPACE::GetFiles
GCBASE_API void GetFiles(const gcstring &FileTemplate, gcstring_vector &FileNames, const bool DirectoriesOnly=false)
Gets a list of files or directories matching a given FileTemplate.
GENICAM_NAMESPACE::GetCandidateCacheFilePaths
GCBASE_API void GetCandidateCacheFilePaths(gcstring_vector &CacheFileNames, const gcstring &CacheFileDirectory)
GCTypes.h
Platform-dependent type definitions.
GENICAM_NAMESPACE::GetCacheFileDirectory
GCBASE_API bool GetCacheFileDirectory(gcstring &CacheFileDirectory)
Returns the directory where cache files are located.
int64_t
__int64 int64_t
Definition: config-win32.h:21
GENICAM_NAMESPACE::ReplaceEnvironmentVariables
GCBASE_API void ReplaceEnvironmentVariables(gcstring &Buffer, bool ReplaceBlankBy20=false)
Replaces in a string and replace ' ' with %20.
RUNTIME_EXCEPTION
#define RUNTIME_EXCEPTION
Fires a runtime exception, e.g. throw RUNTIME_EXCEPTION("buh!")
Definition: GCException.h:247
GENICAM_NAMESPACE::SetGenICamLogConfig
GCBASE_API void SetGenICamLogConfig(const gcstring &path)
Stores the path of the GenICam logging properties file.
GCException.h
GENICAM_NAMESPACE::HasValidExtension
GCBASE_API bool HasValidExtension(const gcstring &FileName)
Returns the truth value for the proposition: The given file has the valid file extension.
GENICAM_NAMESPACE::GetGenICamCLProtocolFolder
GCBASE_API gcstring GetGenICamCLProtocolFolder(void)
Retrieve the path of the CLProtocol folder.
GENICAM_NAMESPACE::DoesEnvironmentVariableExist
GCBASE_API bool DoesEnvironmentVariableExist(const gcstring &VariableName)
Returns true if an environment variable exists.
GENICAM_NAMESPACE::GetModulePathFromFunction
GCBASE_API gcstring GetModulePathFromFunction(void *pFunction)
true = only subdirectories (ex . and ..) are retrieved; false = only files are retrieved
GCString.h
Portable string implementation.


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Wed Dec 4 2024 03:10:11