Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
includeLinks/TSTTUtil.hpp
Go to the documentation of this file.
1 #ifndef TSTT_UTIL_HPP
2 #define TSTT_UTIL_HPP
3 
4 #include <sidl_cxx.hh>
5 #include "TSTTB.hh"
6 
7 namespace Mesquite {
8 
9 static inline msq_std::string process_tstt_error( TSTTB::Error &tstt_err )
10 {
11  msq_std::string str;
12  msq_std::string result("TSTT ERROR: ");
13  result += tstt_err.getNote();
14  MSQ_DBGOUT(1) << "TSTT Error:" << msq_std::endl;
15  MSQ_DBGOUT(1) << tstt_err.getNote() << msq_std::endl;
16  tstt_err.getDescription(str);
17  MSQ_DBGOUT(1) << str << msq_std::endl;
18  MSQ_DBGOUT(1) << tstt_err.getTrace() << msq_std::endl;
19  return result;
20 }
21 
22 template <class T> static inline
23 T* convert_from_sidl_vector( sidl::array<T>& array )
24 { return reinterpret_cast<T*>(array._get_ior()->d_firstElement); }
25 
26 template <class T> static inline sidl::array<T> alloc_sidl_vector( size_t size )
27 {
28  int32_t lower = 0;
29  int32_t upper = size - 1;
30  return sidl::array<T>::createCol( 1, &lower, &upper );
31 }
32 
33 template <class T> static inline sidl::array<T> alloc_sidl_vector( size_t size, T init )
34 {
35  sidl::array<T> result = alloc_sidl_vector<T>(size);
36  T* ptr = convert_from_sidl_vector( result );
37  for ( T* const end = ptr + size; ptr != end; ++ptr)
38  *ptr = init;
39  return result;
40 }
41 
42 template <class S, class T> static inline void copy_from_sidl( sidl::array<S>& source,
43  T* target )
44 {
45  typename sidl::array<S>::iterator i = source.begin();
46  for (; i != source.end(); ++i, ++target)
47  *target = (T)*i;
48 }
49 
50 template <class T> static inline
51 sidl::array<T> convert_to_sidl_vector( T* array, size_t size )
52 {
53  sidl::array<T> result;
54  int32_t lower = 0, upper = size - 1, stride = 1;
55  result.borrow( array, 1, &lower, &upper, &stride );
56  return result;
57 }
58 
59 } // namespace Mesquite
60 
61 #endif
static sidl::array< T > alloc_sidl_vector(size_t size)
static T * convert_from_sidl_vector(sidl::array< T > &array)
static sidl::array< T > convert_to_sidl_vector(T *array, size_t size)
static void copy_from_sidl(sidl::array< S > &source, T *target)
blockLoc i
Definition: read.cpp:79
#define MSQ_DBGOUT(flag)
Check debug flag and return ostream associated with flag.
static msq_std::string process_tstt_error(TSTTB::Error &tstt_err)