From: Patrik Gornicz Date: Fri, 1 May 2009 21:53:17 +0000 (-0400) Subject: name spaced library X-Git-Tag: libbear-premerge~98 X-Git-Url: http://gitweb.pgornicz.com/?a=commitdiff_plain;h=314569944e93cfbd381f25855fb91420149fbbf3;p=libbear.git name spaced library --- diff --git a/Makefile b/Makefile index f41cb7d..b062fc2 100644 --- a/Makefile +++ b/Makefile @@ -90,8 +90,8 @@ ${TARGETTMP}: ${OBJS} ${TARGET}: ${TARGETTMP} | ${WORKINGDIR} ${Q1}${PRNTFMT} "cp" "$@" ${Q2}cp $< $@ - ${Q2}ln -s ${REALNAME} ${WORKINGDIR}/${LINKERNAME} - ${Q2}ln -s ${REALNAME} ${WORKINGDIR}/${SONAME} + ${Q2}ln -sfn ${REALNAME} ${WORKINGDIR}/${LINKERNAME} + ${Q2}ln -sfn ${REALNAME} ${WORKINGDIR}/${SONAME} # how to make a directory ${BLDDIRS}: diff --git a/inc/Autolock.h b/inc/Autolock.h index de0107c..f845f1e 100644 --- a/inc/Autolock.h +++ b/inc/Autolock.h @@ -19,26 +19,31 @@ #ifndef AUTOLOCK_H #define AUTOLOCK_H -class Mutex; - -/// ***** Header Class ***** -class Autolock +namespace pg { -public: - Autolock(Mutex& mu); - ~Autolock(); - void Lock(); - void Unlock(); + class Mutex; + + /// ***** Header Class ***** + class Autolock + { + public: + Autolock(Mutex& mu); + ~Autolock(); + + void Lock(); + void Unlock(); + + // hide copying methods! + private: + Autolock(const Autolock&); + const Autolock& operator ==(const Autolock&); -// hide copying methods! -private: - Autolock(const Autolock&); - const Autolock& operator ==(const Autolock&); + private: + Mutex& m_mu; + }; -private: - Mutex& m_mu; -}; +} // namespace pg /// ***** Header Methods ***** diff --git a/inc/Mutex.h b/inc/Mutex.h index cac4d94..4ba02e5 100644 --- a/inc/Mutex.h +++ b/inc/Mutex.h @@ -19,32 +19,37 @@ #ifndef MUTEX_H #define MUTEX_H -/// ***** Header Class ***** - class SDL_mutex; -class Mutex +namespace pg { -public: - Mutex(); - ~Mutex(); - void init(); - void clean(); + /// ***** Header Class ***** + + class Mutex + { + public: + Mutex(); + ~Mutex(); + + void init(); + void clean(); + + bool IsValid(); - bool IsValid(); + void Lock(); + void Unlock(); - void Lock(); - void Unlock(); + // hide copying methods! + private: + Mutex(const Mutex&); + const Mutex& operator ==(const Mutex&); -// hide copying methods! -private: - Mutex(const Mutex&); - const Mutex& operator ==(const Mutex&); + private: + SDL_mutex* m_pSDL_mutex; + unsigned int m_uiThreadID; + }; -private: - SDL_mutex* m_pSDL_mutex; - unsigned int m_uiThreadID; -}; +} // namespace pg #endif // MUTEX_H diff --git a/inc/Vector2.h b/inc/Vector2.h index 57a5541..96cfc28 100644 --- a/inc/Vector2.h +++ b/inc/Vector2.h @@ -22,48 +22,53 @@ using std::string; -/// ***** Header Class ***** -class Vector2 +namespace pg { - public: - float m_fX; - float m_fY; - Vector2(); - Vector2(float, float); + /// ***** Header Class ***** + class Vector2 + { + public: + float m_fX; + float m_fY; - void zero(); - void unit(); + Vector2(); + Vector2(float, float); - float angle() const; - float length() const; - float sqrLength() const; + void zero(); + void unit(); - float dot(const Vector2&) const; + float angle() const; + float length() const; + float sqrLength() const; - Vector2 add(const Vector2&) const; - Vector2 subtract(const Vector2&) const; - Vector2 divide(float) const; - Vector2 multiply(float) const; + float dot(const Vector2&) const; - string toString() const; - void print() const; -}; + Vector2 add(const Vector2&) const; + Vector2 subtract(const Vector2&) const; + Vector2 divide(float) const; + Vector2 multiply(float) const; -/// ***** Header Methods ***** + string toString() const; + void print() const; + }; -// definitions of the operators are external because (float, Vector2) would -// fail inside the class + /// ***** Header Methods ***** -Vector2 operator+(const Vector2&, const Vector2&); -Vector2 operator-(const Vector2&, const Vector2&); -Vector2 operator*(float, const Vector2&); -Vector2 operator*(const Vector2&, float); -Vector2 operator/(const Vector2&, float); + // definitions of the operators are external to Vector2 because + // methodname(float, Vector2) would fail inside the class -void operator+=(Vector2&, const Vector2&); -void operator-=(Vector2&, const Vector2&); -void operator*=(Vector2&, float); -void operator/=(Vector2&, float); + Vector2 operator+(const Vector2&, const Vector2&); + Vector2 operator-(const Vector2&, const Vector2&); + Vector2 operator*(float, const Vector2&); + Vector2 operator*(const Vector2&, float); + Vector2 operator/(const Vector2&, float); + + void operator+=(Vector2&, const Vector2&); + void operator-=(Vector2&, const Vector2&); + void operator*=(Vector2&, float); + void operator/=(Vector2&, float); + +} // namespace pg #endif // VECTOR2_H diff --git a/inc/debug.h b/inc/debug.h index 6085003..f6ea414 100644 --- a/inc/debug.h +++ b/inc/debug.h @@ -23,15 +23,20 @@ using std::cout; using std::cerr; using std::endl; -void DPF(int level, const char* pstr); - -namespace debug +namespace pg { - void init(); - void clean(); -} -void DASSERT(bool fBreak); + void DPF(int level, const char* pstr); + + namespace debug + { + void init(); + void clean(); + } + + void DASSERT(bool fBreak); + +} // namespace pg // comment out when not debugging #define DEBUGGING diff --git a/inc/mathw.h b/inc/mathw.h index 26a92d8..3034f35 100644 --- a/inc/mathw.h +++ b/inc/mathw.h @@ -22,33 +22,38 @@ #include "Vector2.h" -/// ***** Public Variables ***** +namespace pg +{ -static const float PI = 3.1415926535897; + /// ***** Public Variables ***** -/// ***** Header Methods ***** + static const float PI = 3.1415926535897; -int mod(int, int); + /// ***** Header Methods ***** -/// Vector2 Math + int mod(int, int); -Vector2 vectorToLine -( - const Vector2& vec, - float x1, - float y1, - float x2, - float y2 -); + /// Vector2 Math -//Vector2 lineIntersection(Vector2&, Vector2&, Vector2&, Vector2&) const; + Vector2 vectorToLine + ( + const Vector2& vec, + float x1, + float y1, + float x2, + float y2 + ); -//void Rotate(float rads); + //Vector2 lineIntersection(Vector2&, Vector2&, Vector2&, Vector2&) const; -float dot(const Vector2&, const Vector2&); -Vector2 perp(const Vector2&); + //void Rotate(float rads); -//TODO float projectionCoeff(const Vector2&, const Vector2&) const; -//TODO void projection(const Vector2&, const Vector2&); + float dot(const Vector2&, const Vector2&); + Vector2 perp(const Vector2&); + + //TODO float projectionCoeff(const Vector2&, const Vector2&) const; + //TODO void projection(const Vector2&, const Vector2&); + +} // namespace pg #endif // MATHW_H diff --git a/src/Vector2.cpp b/src/Vector2.cpp index 2a8c8af..a0bc445 100644 --- a/src/Vector2.cpp +++ b/src/Vector2.cpp @@ -20,6 +20,9 @@ #include "mathw.h" +using namespace pg; + + /// ***** Constructors/Destructors ***** Vector2::Vector2() diff --git a/src/debug.cpp b/src/debug.cpp index 0b3c985..69dd332 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -27,6 +27,8 @@ using std::endl; #include "Mutex.h" #include "Autolock.h" +using namespace pg; + /// ***** Public Methods ***** Mutex muDPF; diff --git a/src/locks/Autolock.cpp b/src/locks/Autolock.cpp index 3601bdf..2cf048d 100644 --- a/src/locks/Autolock.cpp +++ b/src/locks/Autolock.cpp @@ -19,6 +19,9 @@ #include "Mutex.h" +using namespace pg; + + /// ***** Constructors/Destructors ***** Autolock::Autolock(Mutex& mu) : m_mu(mu) diff --git a/src/locks/Mutex.cpp b/src/locks/Mutex.cpp index e4004c6..2668669 100644 --- a/src/locks/Mutex.cpp +++ b/src/locks/Mutex.cpp @@ -20,6 +20,9 @@ #include +using namespace pg; + + Mutex::Mutex() : m_pSDL_mutex(NULL) { diff --git a/src/mathw.cpp b/src/mathw.cpp index 2b71dec..7264fd2 100644 --- a/src/mathw.cpp +++ b/src/mathw.cpp @@ -17,6 +17,8 @@ #include "mathw.h" +using namespace pg; + /// ***** Public Methods *****