Commits

Anonymous committed c2645a2

Adding exceptions and collections.
Collections only contain an unimplemented heap for now.

  • Participants
  • Parent commits 5d10b0f

Comments (0)

Files changed (14)

Collections/heap.cpp

Empty file added.

Collections/heap.h

+/** class:     Heap
+  * library:   Bibliotheca
+  * Author:    Lazar Sumar
+  * Date:      31st August 2011
+  * Copyright: GPL, use but please give me due credit.
+  */
+#pragma once
+
+class Heap {
+private:
+
+public:
+	Heap();
+	Heap(const Heap& h);
+	
+	Heap(int n);
+};

Exceptions/CustomExceptions.h

+/** Project: QuadTrack
+  * Section: Custom Exceptions
+  * Author: Lazar Sumar
+  */
+#pragma once
+
+// Standard Library Exception class
+#include <exception>
+
+// Custom exceptions
+#include "IndexOutOfRangeException.h"
+#include "NotImplementedException.h"
+#include "NoDeviceDetectedException.h"

Exceptions/IndexOutOfRangeException.cpp

+#include "IndexOutOfRangeException.h"
+
+void IndexOutOfRangeException::_init(const char* message) {
+	_message = message;
+}
+
+IndexOutOfRangeException::IndexOutOfRangeException () throw() {
+	_init(INDEX_OUT_OF_RANGE_MSG);
+}
+
+IndexOutOfRangeException::IndexOutOfRangeException (const IndexOutOfRangeException& e) throw() {
+	_init(e.what());
+}
+
+IndexOutOfRangeException& IndexOutOfRangeException::operator= (const IndexOutOfRangeException& e) throw() {
+	_init(e.what());
+
+	return *this;
+}
+
+IndexOutOfRangeException::~IndexOutOfRangeException() throw() {
+
+}
+
+const char* IndexOutOfRangeException::what() const throw() {
+	return _message.c_str();
+}

Exceptions/IndexOutOfRangeException.h

+/** Project: QuadTrack
+  * Section: Custom Exceptions
+  * Author: Lazar Sumar
+  */
+#pragma once
+
+#include <exception>
+#include <string>
+
+using namespace std;
+
+#define INDEX_OUT_OF_RANGE_MSG "Index out of range exception thrown!"
+class IndexOutOfRangeException : exception {
+	string _message;
+
+	void _init(const char* message);
+public:
+	IndexOutOfRangeException () throw();
+	IndexOutOfRangeException (const IndexOutOfRangeException&) throw();
+	IndexOutOfRangeException& operator= (const IndexOutOfRangeException&) throw();
+	virtual ~IndexOutOfRangeException() throw();
+	virtual const char* what() const throw();
+};
+
+

Exceptions/NoDeviceDetectedException.cpp

+#include "NoDeviceDetectedException.h"
+
+void NoDeviceDetectedException::_init(const char* message) {
+	_message = message;
+}
+
+NoDeviceDetectedException::NoDeviceDetectedException () throw() {
+	_init(NO_DEVICE_DETECTED_MSG);
+}
+
+NoDeviceDetectedException::NoDeviceDetectedException (const NoDeviceDetectedException& e) throw() {
+	_init(e.what());
+}
+
+NoDeviceDetectedException& NoDeviceDetectedException::operator= (const NoDeviceDetectedException& e) throw() {
+	_init(e.what());
+
+	return *this;
+}
+
+NoDeviceDetectedException::~NoDeviceDetectedException() throw() {
+
+}
+
+const char* NoDeviceDetectedException::what() const throw() {
+	return _message.c_str();
+}

Exceptions/NoDeviceDetectedException.h

+/** Project: QuadTrack
+  * Section: Custom Exceptions
+  * Author: Lazar Sumar
+  */
+#pragma once
+
+#include <exception>
+#include <string>
+
+using namespace std;
+
+#define NO_DEVICE_DETECTED_MSG "No device detected exception!"
+class NoDeviceDetectedException : exception {
+	string _message;
+
+	void _init(const char* message);
+public:
+	NoDeviceDetectedException () throw();
+	NoDeviceDetectedException (const NoDeviceDetectedException&) throw();
+	NoDeviceDetectedException& operator= (const NoDeviceDetectedException&) throw();
+	virtual ~NoDeviceDetectedException() throw();
+	virtual const char* what() const throw();
+};
+
+

Exceptions/NotImplementedException.cpp

+#include "NotImplementedException.h"
+
+void NotImplementedException::_init(const char* message) {
+	_message = message;
+}
+
+NotImplementedException::NotImplementedException () throw() {
+	_init(NOT_IMPLEMENTED_MSG);
+}
+
+NotImplementedException::NotImplementedException (const NotImplementedException& e) throw() {
+	_init(e.what());
+}
+
+NotImplementedException& NotImplementedException::operator= (const NotImplementedException& e) throw() {
+	_init(e.what());
+
+	return *this;
+}
+
+NotImplementedException::~NotImplementedException() throw() {
+
+}
+
+const char* NotImplementedException::what() const throw() {
+	return _message.c_str();
+}

Exceptions/NotImplementedException.h

+/** Project: QuadTrack
+  * Section: Custom Exceptions
+  * Author: Lazar Sumar
+  */
+#pragma once
+
+#include <exception>
+#include <string>
+
+using namespace std;
+
+#define NOT_IMPLEMENTED_MSG "Not implemented exception thrown!"
+class NotImplementedException : exception {
+	string _message;
+
+	void _init(const char* message);
+public:
+	NotImplementedException () throw();
+	NotImplementedException (const NotImplementedException&) throw();
+	NotImplementedException& operator= (const NotImplementedException&) throw();
+	virtual ~NotImplementedException() throw();
+	virtual const char* what() const throw();
+};
+/** Class:        Line, Plane
+  * Library name: Bibliotheca
+  * Author:       Lazar Sumar
+  * Copyright:    GPL 2.0
+  */
 #pragma once
 
 #include <limits>
 /** class:     Point3
+  * library:   Bibliotheca
   * Author:    Lazar Sumar
   * Date:      10th August 2011
   * Copyright: GPL, use but please give me due credit.
 /** class:     Vector3
+  * library:   Bibliotheca
   * Author:    Lazar Sumar
   * Date:      10th August 2011
   * Copyright: GPL, use but please give me due credit.

vs2010/bibliotheca/bibliotheca.vcxproj

     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClInclude Include="..\..\Collections\heap.h" />
+    <ClInclude Include="..\..\Exceptions\CustomExceptions.h" />
+    <ClInclude Include="..\..\Exceptions\IndexOutOfRangeException.h" />
+    <ClInclude Include="..\..\Exceptions\NoDeviceDetectedException.h" />
+    <ClInclude Include="..\..\Exceptions\NotImplementedException.h" />
     <ClInclude Include="..\..\Math\Geometry.h" />
     <ClInclude Include="..\..\Math\Point3.h" />
     <ClInclude Include="..\..\Math\Vector3.h" />
     <ClInclude Include="..\..\Util\NumericStrings.h" />
   </ItemGroup>
   <ItemGroup>
+    <ClCompile Include="..\..\Collections\heap.cpp" />
+    <ClCompile Include="..\..\Exceptions\IndexOutOfRangeException.cpp" />
+    <ClCompile Include="..\..\Exceptions\NoDeviceDetectedException.cpp" />
+    <ClCompile Include="..\..\Exceptions\NotImplementedException.cpp" />
     <ClCompile Include="..\..\Math\Geometry.cpp" />
     <ClCompile Include="..\..\Math\Point3.cpp" />
     <ClCompile Include="..\..\Math\Vector3.cpp" />

vs2010/bibliotheca/bibliotheca.vcxproj.filters

     <Filter Include="Util\Source Files">
       <UniqueIdentifier>{2a2a2460-0605-42b0-b7a6-53592bcd5143}</UniqueIdentifier>
     </Filter>
+    <Filter Include="Collections">
+      <UniqueIdentifier>{a3529eee-2a23-4b21-86d6-440d39c7a923}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Collections\Header Files">
+      <UniqueIdentifier>{193ba39b-65eb-4171-a405-6323536623b7}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Collections\Source Files">
+      <UniqueIdentifier>{f00d57a5-bb5b-42ee-9d51-1b9b21f399c7}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Exceptions">
+      <UniqueIdentifier>{4a5d3e90-5d15-4aea-8550-bf6120f22ce6}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Exceptions\Header Files">
+      <UniqueIdentifier>{708bd491-2c33-4651-b090-a2b38d5f10e6}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Exceptions\Source Files">
+      <UniqueIdentifier>{2e06c57c-a3f2-4aac-bf46-2e0caf7755f8}</UniqueIdentifier>
+    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\Math\Geometry.h">
     <ClInclude Include="..\..\Math\Point3.h">
       <Filter>Math\Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\Collections\heap.h">
+      <Filter>Collections\Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\Exceptions\CustomExceptions.h">
+      <Filter>Exceptions\Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\Exceptions\IndexOutOfRangeException.h">
+      <Filter>Exceptions\Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\Exceptions\NoDeviceDetectedException.h">
+      <Filter>Exceptions\Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\Exceptions\NotImplementedException.h">
+      <Filter>Exceptions\Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\Math\Geometry.cpp">
     <ClCompile Include="..\..\Math\Point3.cpp">
       <Filter>Math\Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\Collections\heap.cpp">
+      <Filter>Collections\Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\Exceptions\IndexOutOfRangeException.cpp">
+      <Filter>Exceptions\Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\Exceptions\NoDeviceDetectedException.cpp">
+      <Filter>Exceptions\Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\Exceptions\NotImplementedException.cpp">
+      <Filter>Exceptions\Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>