21 changed files with 186 additions and 235 deletions
-
0lwrserv/Point.h
-
0lwrserv/SocketObject.cpp
-
0lwrserv/SocketObject.h
-
0lwrserv/StringTool.cpp
-
0lwrserv/StringTool.h
-
0lwrserv/SvrHandling.cpp
-
0lwrserv/SvrHandling.h
-
177lwrserv/config.h
-
0lwrserv/friComm.h
-
0lwrserv/friremote.cpp
-
0lwrserv/friremote.h
-
0lwrserv/friudp.cpp
-
0lwrserv/friudp.h
-
0lwrserv/header.h
-
0lwrserv/include/SvrData.h
-
0lwrserv/include/defines.h
-
8lwrserv/include/mat.h
-
1lwrserv/program.cpp
-
0lwrserv/resource.h
-
0lwrserv/sgn.h
-
235lwrserv/vec.h
@ -0,0 +1,177 @@ |
|||||
|
/* config.h. Generated from config.h.in by configure. */ |
||||
|
/* config.h.in. Generated from configure.ac by autoheader. */ |
||||
|
|
||||
|
/* Compiling CppUTest itself */ |
||||
|
#define CPPUTEST_COMPILATION 1 |
||||
|
|
||||
|
/* memory leak detection disabled */ |
||||
|
/* #undef CPPUTEST_MEM_LEAK_DETECTION_DISABLED */ |
||||
|
|
||||
|
/* Standard C++ library disabled */ |
||||
|
/* #undef CPPUTEST_STD_CPP_LIB_DISABLED */ |
||||
|
|
||||
|
/* Standard C library disabled */ |
||||
|
/* #undef CPPUTEST_STD_C_LIB_DISABLED */ |
||||
|
|
||||
|
/* Define to 1 if you have the <dlfcn.h> header file. */ |
||||
|
#define HAVE_DLFCN_H 1 |
||||
|
|
||||
|
/* Define to 1 if you have the `fork' function. */ |
||||
|
#define HAVE_FORK 1 |
||||
|
|
||||
|
/* Define to 1 if you have the `gettimeofday' function. */ |
||||
|
#define HAVE_GETTIMEOFDAY 1 |
||||
|
|
||||
|
/* Define to 1 if you have the <inttypes.h> header file. */ |
||||
|
#define HAVE_INTTYPES_H 1 |
||||
|
|
||||
|
/* Define to 1 if you have the <memory.h> header file. */ |
||||
|
#define HAVE_MEMORY_H 1 |
||||
|
|
||||
|
/* Define to 1 if you have the `memset' function. */ |
||||
|
#define HAVE_MEMSET 1 |
||||
|
|
||||
|
/* Define if you have POSIX threads libraries and header files. */ |
||||
|
/* #undef HAVE_PTHREAD */ |
||||
|
|
||||
|
/* Define to 1 if you have the <stddef.h> header file. */ |
||||
|
#define HAVE_STDDEF_H 1 |
||||
|
|
||||
|
/* Define to 1 if you have the <stdint.h> header file. */ |
||||
|
#define HAVE_STDINT_H 1 |
||||
|
|
||||
|
/* Define to 1 if you have the <stdlib.h> header file. */ |
||||
|
#define HAVE_STDLIB_H 1 |
||||
|
|
||||
|
/* Define to 1 if you have the <strings.h> header file. */ |
||||
|
#define HAVE_STRINGS_H 1 |
||||
|
|
||||
|
/* Define to 1 if you have the <string.h> header file. */ |
||||
|
#define HAVE_STRING_H 1 |
||||
|
|
||||
|
/* Define to 1 if you have the `strstr' function. */ |
||||
|
#define HAVE_STRSTR 1 |
||||
|
|
||||
|
/* Define to 1 if you have the <sys/stat.h> header file. */ |
||||
|
#define HAVE_SYS_STAT_H 1 |
||||
|
|
||||
|
/* Define to 1 if you have the <sys/time.h> header file. */ |
||||
|
#define HAVE_SYS_TIME_H 1 |
||||
|
|
||||
|
/* Define to 1 if you have the <sys/types.h> header file. */ |
||||
|
#define HAVE_SYS_TYPES_H 1 |
||||
|
|
||||
|
/* Define to 1 if you have the <unistd.h> header file. */ |
||||
|
#define HAVE_UNISTD_H 1 |
||||
|
|
||||
|
/* Define to 1 if you have the `vfork' function. */ |
||||
|
#define HAVE_VFORK 1 |
||||
|
|
||||
|
/* Define to 1 if you have the <vfork.h> header file. */ |
||||
|
/* #undef HAVE_VFORK_H */ |
||||
|
|
||||
|
/* Define to 1 if `fork' works. */ |
||||
|
#define HAVE_WORKING_FORK 1 |
||||
|
|
||||
|
/* Define to 1 if `vfork' works. */ |
||||
|
#define HAVE_WORKING_VFORK 1 |
||||
|
|
||||
|
/* Include the GTest-related tests in the build */ |
||||
|
/* #undef INCLUDE_GTEST_TESTS */ |
||||
|
|
||||
|
/* Define to the sub-directory in which libtool stores uninstalled libraries. |
||||
|
*/ |
||||
|
#define LT_OBJDIR ".libs/" |
||||
|
|
||||
|
/* Name of package */ |
||||
|
#define PACKAGE "cpputest" |
||||
|
|
||||
|
/* Define to the address where bug reports for this package should be sent. */ |
||||
|
#define PACKAGE_BUGREPORT "https://github.com/cpputest/cpputest" |
||||
|
|
||||
|
/* Define to the full name of this package. */ |
||||
|
#define PACKAGE_NAME "CppUTest" |
||||
|
|
||||
|
/* Define to the full name and version of this package. */ |
||||
|
#define PACKAGE_STRING "CppUTest 3.7.1" |
||||
|
|
||||
|
/* Define to the one symbol short name of this package. */ |
||||
|
#define PACKAGE_TARNAME "cpputest" |
||||
|
|
||||
|
/* Define to the home page for this package. */ |
||||
|
#define PACKAGE_URL "" |
||||
|
|
||||
|
/* Define to the version of this package. */ |
||||
|
#define PACKAGE_VERSION "3.7.1" |
||||
|
|
||||
|
/* Define to necessary symbol if this constant uses a non-standard name on |
||||
|
your system. */ |
||||
|
/* #undef PTHREAD_CREATE_JOINABLE */ |
||||
|
|
||||
|
/* Define to 1 if you have the ANSI C header files. */ |
||||
|
#define STDC_HEADERS 1 |
||||
|
|
||||
|
/* Version number of package */ |
||||
|
#define VERSION "3.7.1" |
||||
|
|
||||
|
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>, |
||||
|
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the |
||||
|
#define below would cause a syntax error. */ |
||||
|
/* #undef _UINT32_T */ |
||||
|
|
||||
|
/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>, |
||||
|
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the |
||||
|
#define below would cause a syntax error. */ |
||||
|
/* #undef _UINT64_T */ |
||||
|
|
||||
|
/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>, |
||||
|
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the |
||||
|
#define below would cause a syntax error. */ |
||||
|
/* #undef _UINT8_T */ |
||||
|
|
||||
|
/* Define to `__inline__' or `__inline' if that's what the C compiler |
||||
|
calls it, or to nothing if 'inline' is not supported under any name. */ |
||||
|
#ifndef __cplusplus |
||||
|
/* #undef inline */ |
||||
|
#endif |
||||
|
|
||||
|
/* Define to the type of a signed integer type of width exactly 16 bits if |
||||
|
such a type exists and the standard includes do not define it. */ |
||||
|
/* #undef int16_t */ |
||||
|
|
||||
|
/* Define to the type of a signed integer type of width exactly 32 bits if |
||||
|
such a type exists and the standard includes do not define it. */ |
||||
|
/* #undef int32_t */ |
||||
|
|
||||
|
/* Define to the type of a signed integer type of width exactly 64 bits if |
||||
|
such a type exists and the standard includes do not define it. */ |
||||
|
/* #undef int64_t */ |
||||
|
|
||||
|
/* Define to the type of a signed integer type of width exactly 8 bits if such |
||||
|
a type exists and the standard includes do not define it. */ |
||||
|
/* #undef int8_t */ |
||||
|
|
||||
|
/* Define to `int' if <sys/types.h> does not define. */ |
||||
|
/* #undef pid_t */ |
||||
|
|
||||
|
/* Define to `unsigned int' if <sys/types.h> does not define. */ |
||||
|
/* #undef size_t */ |
||||
|
|
||||
|
/* Define to the type of an unsigned integer type of width exactly 16 bits if |
||||
|
such a type exists and the standard includes do not define it. */ |
||||
|
/* #undef uint16_t */ |
||||
|
|
||||
|
/* Define to the type of an unsigned integer type of width exactly 32 bits if |
||||
|
such a type exists and the standard includes do not define it. */ |
||||
|
/* #undef uint32_t */ |
||||
|
|
||||
|
/* Define to the type of an unsigned integer type of width exactly 64 bits if |
||||
|
such a type exists and the standard includes do not define it. */ |
||||
|
/* #undef uint64_t */ |
||||
|
|
||||
|
/* Define to the type of an unsigned integer type of width exactly 8 bits if |
||||
|
such a type exists and the standard includes do not define it. */ |
||||
|
/* #undef uint8_t */ |
||||
|
|
||||
|
/* Define as `fork' if `vfork' does not work. */ |
||||
|
/* #undef vfork */ |
@ -1,235 +0,0 @@ |
|||||
#ifndef _VEC_H_ |
|
||||
#define _VEC_H_ |
|
||||
#include <math.h> |
|
||||
#include "mat.h" |
|
||||
#include <ostream> |
|
||||
|
|
||||
template<class T, unsigned SIZE> class Mat; |
|
||||
template<class T, unsigned SIZE> class Vec; |
|
||||
|
|
||||
// Vector class for SIMPLE data types |
|
||||
template <class T, unsigned SIZE> class Vec |
|
||||
{ |
|
||||
public: |
|
||||
|
|
||||
// standard constructor |
|
||||
Vec<T,SIZE> () |
|
||||
{ // initialize all elements with zero |
|
||||
for (unsigned int i=0; i<SIZE; i++) |
|
||||
m_atData[i] = T(0); |
|
||||
} |
|
||||
|
|
||||
// construction with data array |
|
||||
Vec<T, SIZE> (const T atData[SIZE]) |
|
||||
{ |
|
||||
for (unsigned int i=0; i<SIZE; i++) |
|
||||
m_atData[i] = atData[i]; |
|
||||
} |
|
||||
|
|
||||
// copy constructor |
|
||||
Vec<T, SIZE> (const Vec<T, SIZE> &vec) |
|
||||
{ |
|
||||
if (this==&vec) |
|
||||
return; // nothing to do, it's me |
|
||||
for (unsigned int i=0; i<SIZE; i++) |
|
||||
m_atData[i] = vec.m_atData[i]; |
|
||||
} |
|
||||
|
|
||||
// destructor |
|
||||
~Vec () |
|
||||
{ // nothing to do here ... |
|
||||
} |
|
||||
|
|
||||
void setData (const T atData[SIZE]) |
|
||||
{ |
|
||||
for (unsigned int i=0; i<SIZE; i++) |
|
||||
m_atData[i] = atData[i]; |
|
||||
} |
|
||||
|
|
||||
void getData (const T atData[SIZE]) |
|
||||
{ |
|
||||
for (unsigned int i=0; i<SIZE; i++) |
|
||||
atData[i] = m_atData[i]; |
|
||||
|
|
||||
} |
|
||||
|
|
||||
unsigned getDimension () |
|
||||
{ |
|
||||
return SIZE; |
|
||||
} |
|
||||
|
|
||||
|
|
||||
Vec<T, SIZE> &operator = (const Vec<T, SIZE> &vec) |
|
||||
{ |
|
||||
if (this==&vec) |
|
||||
return (*this); // ok, it's me, so no L-value action |
|
||||
for (unsigned int i=0; i<SIZE; i++) // not me, so L-Value action: copy data |
|
||||
m_atData[i] = vec.m_atData[i]; |
|
||||
|
|
||||
return (*this); // also an R-value in e.g |
|
||||
// vec1 = vec2 = vec3; |
|
||||
// L-Value = R-Value/L-Value = R-Value |
|
||||
} |
|
||||
|
|
||||
Vec<T, SIZE> &operator = (const T atData[SIZE]) |
|
||||
{ |
|
||||
for (unsigned int i=0; i<SIZE; i++) // not me, so L-Value action: copy data |
|
||||
m_atData[i] = atData[i]; |
|
||||
|
|
||||
return (*this); // also an R-value in e.g. |
|
||||
// vec1 = vec2 + (vec2=atData); // parenthesis () needed to evaluate expression vec2=atData |
|
||||
// L-Val = R-Val + R-Val |
|
||||
// " = " + (L-Val = R-Val) |
|
||||
} |
|
||||
|
|
||||
// usage of operator: |
|
||||
// vec(i) = var; // 0 <= i <= SIZE-1 |
|
||||
// var = vec(i); |
|
||||
// vec1(i) = vec2(j); |
|
||||
T &operator () (unsigned i) |
|
||||
{ |
|
||||
if (i>=SIZE) |
|
||||
i = SIZE-1; // !!! operator clips index ... |
|
||||
return m_atData[i]; // ... so we can safely return a reference |
|
||||
} |
|
||||
|
|
||||
T operator () (unsigned i) const |
|
||||
{ |
|
||||
if (i>=SIZE) |
|
||||
i = SIZE-1; |
|
||||
return m_atData[i]; |
|
||||
} |
|
||||
|
|
||||
void operator += (const Vec<T, SIZE> &vec) |
|
||||
{ |
|
||||
for (int i=0; i<SIZE; i++) |
|
||||
m_atData[i] += vec.m_atData[i]; |
|
||||
} |
|
||||
|
|
||||
Vec<T, SIZE> operator + (const Vec<T, SIZE> &vec) |
|
||||
{ |
|
||||
Vec<T, SIZE> buf (m_atData); |
|
||||
for (unsigned int i=0; i<SIZE; i++) |
|
||||
buf.m_atData[i] += vec.m_atData[i]; |
|
||||
return buf; |
|
||||
} |
|
||||
|
|
||||
void operator -= (const Vec<T, SIZE> &vec) |
|
||||
{ |
|
||||
for (unsigned int i=0; i<SIZE; i++) |
|
||||
m_atData[i] -= vec.m_atData[i]; |
|
||||
} |
|
||||
|
|
||||
// binary - |
|
||||
// vec1 - vec2 i.e. (*this) - vec |
|
||||
Vec<T, SIZE> operator - (const Vec<T, SIZE> &vec) |
|
||||
{ |
|
||||
Vec<T, SIZE> buf (m_atData); |
|
||||
for (unsigned int i=0; i<SIZE; i++) |
|
||||
buf.m_atData[i] -= vec.m_atData[i]; |
|
||||
return buf; |
|
||||
} |
|
||||
|
|
||||
// unary - |
|
||||
// -vec i.e. -(*this) |
|
||||
Vec<T, SIZE> operator - () |
|
||||
{ |
|
||||
T atBuffer[SIZE]; |
|
||||
for (int i=0; i<SIZE; i++) |
|
||||
atBuffer[i] = -m_atData[i]; |
|
||||
return Vec<T, SIZE> (atBuffer); |
|
||||
} |
|
||||
|
|
||||
T operator * (const Vec<T, SIZE> & vec) |
|
||||
{ |
|
||||
T dp = T(0); |
|
||||
for (int i=0; i<SIZE; i++) |
|
||||
dp += m_atData[i]*vec.m_atData[i]; |
|
||||
return dp; |
|
||||
} |
|
||||
|
|
||||
void operator *= (T tScale) |
|
||||
{ |
|
||||
for (unsigned int i=0; i<SIZE; i++) |
|
||||
m_atData[i] *= tScale; |
|
||||
} |
|
||||
|
|
||||
Vec<T, SIZE> operator * (T tScale) |
|
||||
{ |
|
||||
T atBuffer[SIZE]; |
|
||||
for (unsigned int i=0; i<SIZE; i++) |
|
||||
atBuffer[i] = m_atData[i]*tScale; |
|
||||
return Vec<T, SIZE> (atBuffer); |
|
||||
} |
|
||||
|
|
||||
Vec<T, SIZE> operator * (const Mat<T, SIZE> &mat) |
|
||||
{ |
|
||||
Vec<T, SIZE> vec; |
|
||||
for (unsigned int j=0; j<SIZE; j++) |
|
||||
for (unsigned int i=0; i<SIZE; i++) |
|
||||
vec(j) += m_atData[i]*mat(i,j); |
|
||||
return vec; |
|
||||
} |
|
||||
|
|
||||
T norm () |
|
||||
{ |
|
||||
T retval = 0; |
|
||||
|
|
||||
// this * this |
|
||||
for (int i=0; i<SIZE; i++) |
|
||||
retval += m_atData[i] * m_atData[i]; |
|
||||
sqrt(retval); |
|
||||
return retval; |
|
||||
} |
|
||||
|
|
||||
Vec<T, SIZE> x(const Vec<T, SIZE> &vec) |
|
||||
{ |
|
||||
T temp[SIZE]; |
|
||||
temp[0] = m_atData[1]*vec(2) - m_atData[2]*vec(1); |
|
||||
temp[1] = m_atData[2]*vec(0) - m_atData[0]*vec(2); |
|
||||
temp[2] = m_atData[0]*vec(1) - m_atData[1]*vec(0); |
|
||||
temp[3] = vec(3); |
|
||||
return Vec<T, SIZE> (temp); |
|
||||
} |
|
||||
|
|
||||
private: |
|
||||
|
|
||||
T m_atData[SIZE]; |
|
||||
|
|
||||
}; // class Vec |
|
||||
|
|
||||
|
|
||||
// some common vector classes (abbr. names) |
|
||||
typedef Vec<float, 2> Vec2f; |
|
||||
typedef Vec<float, 3> Vec3f; |
|
||||
typedef Vec<float, 4> Vec4f; |
|
||||
|
|
||||
typedef Vec<double, 2> Vec2d; |
|
||||
typedef Vec<double, 3> Vec3d; |
|
||||
typedef Vec<double, 4> Vec4d; |
|
||||
|
|
||||
typedef Vec<int, 2> Vec2i; |
|
||||
typedef Vec<int, 3> Vec3i; |
|
||||
typedef Vec<int, 4> Vec4i; |
|
||||
|
|
||||
typedef Vec<bool, 2> Vec2b; |
|
||||
typedef Vec<bool, 3> Vec3b; |
|
||||
typedef Vec<bool, 4> Vec4b; |
|
||||
|
|
||||
|
|
||||
template <class T, unsigned SIZE> |
|
||||
static std::ostream& operator<< (std::ostream& output,const Vec<T,SIZE> &vec) |
|
||||
{ |
|
||||
output << "( "; |
|
||||
for(unsigned int i = 0 ; i< SIZE; ++i) |
|
||||
{ |
|
||||
output << vec(i); |
|
||||
if (i<SIZE-1) |
|
||||
output << " , "; |
|
||||
else |
|
||||
output << " )"; |
|
||||
} |
|
||||
return output; |
|
||||
} |
|
||||
|
|
||||
#endif |
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue