Commit 8fc1002e by Jessica Hawkwell

halp

1 parent ab7acabc
...@@ -4,8 +4,32 @@ set(CMAKE_CXX_STANDARD 14) ...@@ -4,8 +4,32 @@ set(CMAKE_CXX_STANDARD 14)
set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD 11)
set(CMAKE_BUILD_TYPE Debug) set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY build/bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ./build/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY build/lib) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ./build/lib)
set(CMAKE_LIBRARY_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 @@ ...@@ -15,6 +15,9 @@
<in>feature_tests.cxx</in> <in>feature_tests.cxx</in>
</df> </df>
<df name="src"> <df name="src">
<df name="libnde">
<in>NPosition.cpp</in>
</df>
<df name="NitroWin"> <df name="NitroWin">
<df name="CMakeFiles"> <df name="CMakeFiles">
<df name="3.10.2"> <df name="3.10.2">
...@@ -28,8 +31,6 @@ ...@@ -28,8 +31,6 @@
<in>feature_tests.c</in> <in>feature_tests.c</in>
<in>feature_tests.cxx</in> <in>feature_tests.cxx</in>
</df> </df>
<in>NPosition.h</in>
<in>NSize.h</in>
<in>NUtils.cpp</in> <in>NUtils.cpp</in>
<in>NUtils.h</in> <in>NUtils.h</in>
<in>NWMAction.cpp</in> <in>NWMAction.cpp</in>
...@@ -117,10 +118,6 @@ ...@@ -117,10 +118,6 @@
tool="1" tool="1"
flavor2="0"> flavor2="0">
</item> </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 path="src/NitroWin/NUtils.cpp" ex="false" tool="1" flavor2="0">
</item> </item>
<item path="src/NitroWin/NUtils.h" ex="false" tool="3" flavor2="0"> <item path="src/NitroWin/NUtils.h" ex="false" tool="3" flavor2="0">
...@@ -135,6 +132,8 @@ ...@@ -135,6 +132,8 @@
</item> </item>
<item path="src/NitroWin/main.cpp" ex="false" tool="1" flavor2="0"> <item path="src/NitroWin/main.cpp" ex="false" tool="1" flavor2="0">
</item> </item>
<item path="src/libnde/NPosition.cpp" ex="false" tool="1" flavor2="0">
</item>
</conf> </conf>
</confs> </confs>
</configurationDescriptor> </configurationDescriptor>
...@@ -6,5 +6,5 @@ include_directories("/usr/local/include") ...@@ -6,5 +6,5 @@ include_directories("/usr/local/include")
link_libraries(${X11_LIBRARIES}) link_libraries(${X11_LIBRARIES})
file(GLOB nwin "*.cpp") add_executable(${PROJECT_NAME} NUtils.cpp NWMAction.cpp NWManager.cpp main.cpp)
add_executable(NitroWin ${nwin}) target_link_libraries(${PROJECT_NAME} LINK_PUBLIC nde)
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#include <vector> #include <vector>
#include <unordered_map> #include <unordered_map>
#include "NPosition.h" #include <NPosition.h>
#include "NSize.h" #include "NSize.h"
class NWMAction { 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. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
...@@ -16,75 +16,74 @@ ...@@ -16,75 +16,74 @@
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 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 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * 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 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef NPOSITION_H #include "NPosition.h"
#define NPOSITION_H
#include <string>
template <typename T> template <typename T>
class NPosition __attribute__ ((__visibility__("default")))
{ NPosition<T>::NPosition(T x, T y) {
protected: px = x;
T px; py = y;
T py; }
public:
NPosition<T>(T x, T y) {
px = x;
py = y;
}
NPosition<T>(const NPosition<T>& other) {
px = other.px;
py = other.py;
}
NPosition<T>& operator=(const NPosition<T>& other) { template <typename T>
px = other.px; __attribute__ ((__visibility__("default")))
py = other.py; NPosition<T>::NPosition(const NPosition<T>& other) {
return *this; px = other.px;
} py = other.py;
}
NPosition<T> operator+(const NPosition<T>& other) { template <typename T>
NPosition<T> rt = NPosition<T>(px + other.px, py + other.py); NPosition<T>& NPosition<T>::operator=(const NPosition<T>&& other) {
return rt; px = other.px;
} py = other.py;
return *this;
}
NPosition<T> operator-(const NPosition<T>& other) { template <typename T>
NPosition<T> rt = NPosition<T>(px - other.px, py - other.py); NPosition<T> NPosition<T>::operator+(const NPosition<T>& other) {
return rt; NPosition<T> rt = NPosition<T>(px + other.px, py + other.py);
} return rt;
}
bool operator==(const NPosition<T>& other) const { template <typename T>
if (px != other.getX()) { return false; } NPosition<T> NPosition<T>::operator-(const NPosition<T>& other) {
if (py != other.getY()) { return false; } NPosition<T> rt = NPosition<T>(px - other.px, py - other.py);
return true; return rt;
} }
std::string toString() { template <typename T>
std::string out = std::string(); bool NPosition<T>::operator==(const NPosition<T>& other) const {
out.append("("); if (px != other.getX()) { return false; }
out.append(std::to_string(px)); if (py != other.getY()) { return false; }
out.append(", "); return true;
out.append(std::to_string(py)); }
out.append(")");
return out;
}
T getX() { return px; } template <typename T>
T getY() { return py; } std::string NPosition<T>::toString() {
std::string out = std::string();
out.append("(");
out.append(std::to_string(px));
out.append(", ");
out.append(std::to_string(py));
out.append(")");
return out;
}
void setZeroIfNegative() { template <typename T>
if (px < 0) { px = 0; } T NPosition<T>::getX() { return px; }
if (py < 0) { py = 0;} template <typename T>
} T NPosition<T>::getY() { return py; }
};
#endif // NPOSITION_H template <typename T>
void NPosition<T>::setZeroIfNegative() {
if (px < 0) { px = 0; }
if (py < 0) { py = 0;}
}
/*
* 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!