Commit 8fc1002e by Jessica Hawkwell

halp

1 parent ab7acabc
......@@ -4,8 +4,32 @@ set(CMAKE_CXX_STANDARD 14)
set(CMAKE_C_STANDARD 11)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY build/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY build/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY build/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ./build/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ./build/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ./build/lib)
add_subdirectory(src/NitroWin)
project(nde)
include_directories("/usr/local/include")
add_library(${PROJECT_NAME} SHARED src/libnde/NPosition.cpp)
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib/${PROJECT_NAME})
file(GLOB HEADERS "src/libnde/*.h")
install(FILES ${HEADERS} DESTINATION include/${PROJECT_NAME})
target_include_directories (nde PUBLIC "src/libnde")
project (NitroWin)
find_package(X11)
include_directories("/usr/local/include")
link_libraries(${X11_LIBRARIES})
add_executable(${PROJECT_NAME}
src/NitroWin/NUtils.cpp
src/NitroWin/NWMAction.cpp
src/NitroWin/NWManager.cpp
src/NitroWin/main.cpp)
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC nde)
......@@ -15,6 +15,9 @@
<in>feature_tests.cxx</in>
</df>
<df name="src">
<df name="libnde">
<in>NPosition.cpp</in>
</df>
<df name="NitroWin">
<df name="CMakeFiles">
<df name="3.10.2">
......@@ -28,8 +31,6 @@
<in>feature_tests.c</in>
<in>feature_tests.cxx</in>
</df>
<in>NPosition.h</in>
<in>NSize.h</in>
<in>NUtils.cpp</in>
<in>NUtils.h</in>
<in>NWMAction.cpp</in>
......@@ -117,10 +118,6 @@
tool="1"
flavor2="0">
</item>
<item path="src/NitroWin/NPosition.h" ex="false" tool="3" flavor2="0">
</item>
<item path="src/NitroWin/NSize.h" ex="false" tool="3" flavor2="0">
</item>
<item path="src/NitroWin/NUtils.cpp" ex="false" tool="1" flavor2="0">
</item>
<item path="src/NitroWin/NUtils.h" ex="false" tool="3" flavor2="0">
......@@ -135,6 +132,8 @@
</item>
<item path="src/NitroWin/main.cpp" ex="false" tool="1" flavor2="0">
</item>
<item path="src/libnde/NPosition.cpp" ex="false" tool="1" flavor2="0">
</item>
</conf>
</confs>
</configurationDescriptor>
......@@ -6,5 +6,5 @@ include_directories("/usr/local/include")
link_libraries(${X11_LIBRARIES})
file(GLOB nwin "*.cpp")
add_executable(NitroWin ${nwin})
add_executable(${PROJECT_NAME} NUtils.cpp NWMAction.cpp NWManager.cpp main.cpp)
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC nde)
......@@ -38,7 +38,7 @@
#include <vector>
#include <unordered_map>
#include "NPosition.h"
#include <NPosition.h>
#include "NSize.h"
class NWMAction {
......
cmake_minimum_required (VERSION 3.10)
project (nde)
include_directories("/usr/local/include")
add_library(${PROJECT_NAME} SHARED PUBLIC NPosition.cpp)
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib/${PROJECT_NAME})
file(GLOB HEADERS "*.h")
install(FILES ${HEADERS} DESTINATION include/${PROJECT_NAME})
target_include_directories (nde PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
/*
* Copyright(c) 2018, jlhawkwell
* Copyright (c) 2018, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
......@@ -16,59 +16,58 @@
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE)
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef NPOSITION_H
#define NPOSITION_H
#include <string>
#include "NPosition.h"
template <typename T>
class NPosition
{
protected:
T px;
T py;
public:
NPosition<T>(T x, T y) {
__attribute__ ((__visibility__("default")))
NPosition<T>::NPosition(T x, T y) {
px = x;
py = y;
}
}
NPosition<T>(const NPosition<T>& other) {
template <typename T>
__attribute__ ((__visibility__("default")))
NPosition<T>::NPosition(const NPosition<T>& other) {
px = other.px;
py = other.py;
}
}
NPosition<T>& operator=(const NPosition<T>& other) {
template <typename T>
NPosition<T>& NPosition<T>::operator=(const NPosition<T>&& other) {
px = other.px;
py = other.py;
return *this;
}
}
NPosition<T> operator+(const NPosition<T>& other) {
template <typename T>
NPosition<T> NPosition<T>::operator+(const NPosition<T>& other) {
NPosition<T> rt = NPosition<T>(px + other.px, py + other.py);
return rt;
}
}
NPosition<T> operator-(const NPosition<T>& other) {
template <typename T>
NPosition<T> NPosition<T>::operator-(const NPosition<T>& other) {
NPosition<T> rt = NPosition<T>(px - other.px, py - other.py);
return rt;
}
}
bool operator==(const NPosition<T>& other) const {
template <typename T>
bool NPosition<T>::operator==(const NPosition<T>& other) const {
if (px != other.getX()) { return false; }
if (py != other.getY()) { return false; }
return true;
}
}
std::string toString() {
template <typename T>
std::string NPosition<T>::toString() {
std::string out = std::string();
out.append("(");
out.append(std::to_string(px));
......@@ -76,15 +75,15 @@ public:
out.append(std::to_string(py));
out.append(")");
return out;
}
}
T getX() { return px; }
T getY() { return py; }
template <typename T>
T NPosition<T>::getX() { return px; }
template <typename T>
T NPosition<T>::getY() { return py; }
void setZeroIfNegative() {
template <typename T>
void NPosition<T>::setZeroIfNegative() {
if (px < 0) { px = 0; }
if (py < 0) { py = 0;}
}
};
#endif // NPOSITION_H
}
/*
* Copyright(c) 2018, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef NPOSITION_H
#define NPOSITION_H
#include <string>
template <typename T>
class __attribute__ ((__visibility__("default"))) NPosition
{
protected:
T px;
T py;
public:
__attribute__ ((__visibility__("default")))
NPosition<T>(T x, T y);
__attribute__ ((__visibility__("default")))
NPosition<T>(const NPosition<T>& other);
__attribute__ ((__visibility__("default")))
NPosition<T>& operator=(const NPosition<T>&& other);
__attribute__ ((__visibility__("default")))
NPosition<T> operator+(const NPosition<T>& other);
__attribute__ ((__visibility__("default")))
NPosition<T> operator-(const NPosition<T>& other);
__attribute__ ((__visibility__("default")))
bool operator==(const NPosition<T>& other) const;
__attribute__ ((__visibility__("default")))
std::string toString();
__attribute__ ((__visibility__("default")))
T getX();
__attribute__ ((__visibility__("default")))
T getY();
__attribute__ ((__visibility__("default")))
void setZeroIfNegative();
};
#endif // NPOSITION_H
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!