Skip to content

Commit

Permalink
libdeng2: Added Range, relocated Matrix, Vector, Rectangle, Version t…
Browse files Browse the repository at this point in the history
…o core
  • Loading branch information
skyjake committed May 22, 2013
1 parent abef597 commit eec0efc
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 25 deletions.
2 changes: 1 addition & 1 deletion doomsday/libdeng2/include/de/Matrix
@@ -1 +1 @@
#include "matrix.h"
#include "core/matrix.h"
1 change: 1 addition & 0 deletions doomsday/libdeng2/include/de/Range
@@ -0,0 +1 @@
#include "core/range.h"
2 changes: 1 addition & 1 deletion doomsday/libdeng2/include/de/Rectangle
@@ -1 +1 @@
#include "rectangle.h"
#include "core/rectangle.h"
2 changes: 1 addition & 1 deletion doomsday/libdeng2/include/de/Vector
@@ -1 +1 @@
#include "vector.h"
#include "core/vector.h"
2 changes: 1 addition & 1 deletion doomsday/libdeng2/include/de/Version
@@ -1 +1 @@
#include "version.h"
#include "core/version.h"
Expand Up @@ -20,13 +20,13 @@
#ifndef LIBDENG2_MATRIX_H
#define LIBDENG2_MATRIX_H

#include "libdeng2.h"
#include "math.h"
#include "Vector"
#include "Writer"
#include "Reader"
#include "String"
#include "ByteRefArray"
#include "../libdeng2.h"
#include "../math.h"
#include "../Vector"
#include "../Writer"
#include "../Reader"
#include "../String"
#include "../ByteRefArray"

#include <QTextStream>

Expand Down
52 changes: 52 additions & 0 deletions doomsday/libdeng2/include/de/core/range.h
@@ -0,0 +1,52 @@
/** @file range.h Linear range.
*
* @authors Copyright (c) 2013 Jaakko Keränen <jaakko.keranen@iki.fi>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
*/

#ifndef LIBDENG2_RANGE_H
#define LIBDENG2_RANGE_H

#include "../libdeng2.h"

namespace de {

/**
* Linear value range. The start point is inclusive while the end point is
* exclusive. The end point should be larger in value than the start point.
*/
template <typename Type>
struct Range
{
Type start;
Type end;

Range(Type const &a = 0, Type const &b = 0) : start(a), end(b) {}
inline Type size() const { return end - start; }
inline bool contains(Type const &i) const { return i >= start && i < end; }
inline bool operator == (Range const &other) const {
return start == other.start && end == other.end;
}
};

typedef Range<dint32> Rangei;
typedef Range<duint32> Rangeui;
typedef Range<dint64> Rangei64;
typedef Range<dfloat> Rangef;
typedef Range<ddouble> Ranged;

} // namespace de

#endif // LIBDENG2_RANGE_H
Expand Up @@ -20,7 +20,7 @@
#ifndef LIBDENG2_RECTANGLE_H
#define LIBDENG2_RECTANGLE_H

#include "Vector"
#include "../Vector"
#include <QRect>

#ifdef WIN32
Expand Down
Expand Up @@ -21,12 +21,12 @@
#ifndef LIBDENG2_VECTOR_H
#define LIBDENG2_VECTOR_H

#include "math.h"
#include "Error"
#include "ISerializable"
#include "Writer"
#include "Reader"
#include "String"
#include "../math.h"
#include "../Error"
#include "../ISerializable"
#include "../Writer"
#include "../Reader"
#include "../String"

#include <QTextStream>
#include <cmath>
Expand Down
Expand Up @@ -25,8 +25,8 @@

#ifdef __cplusplus

#include <de/String>
#include <de/Time>
#include "../String"
#include "../Time"

namespace de {

Expand Down
12 changes: 7 additions & 5 deletions doomsday/libdeng2/libdeng2.pro
Expand Up @@ -82,6 +82,7 @@ HEADERS += \
include/de/Matrix \
include/de/MemoryLogSink \
include/de/MonospaceLogSinkFormatter \
include/de/Range \
include/de/Rectangle \
include/de/System \
include/de/TextApp \
Expand All @@ -95,10 +96,6 @@ HEADERS += \
include/de/error.h \
include/de/libdeng2.h \
include/de/math.h \
include/de/matrix.h \
include/de/rectangle.h \
include/de/vector.h \
include/de/version.h \
include/de/core/app.h \
include/de/core/asset.h \
include/de/core/clock.h \
Expand All @@ -113,12 +110,17 @@ HEADERS += \
include/de/core/logbuffer.h \
include/de/core/logsink.h \
include/de/core/loop.h \
include/de/core/matrix.h \
include/de/core/memorylogsink.h \
include/de/core/monospacelogsinkformatter.h \
include/de/core/range.h \
include/de/core/rectangle.h \
include/de/core/system.h \
include/de/core/textapp.h \
include/de/core/textstreamlogsink.h \
include/de/core/unixinfo.h
include/de/core/unixinfo.h \
include/de/core/vector.h \
include/de/core/version.h

# Private headers.
HEADERS += \
Expand Down

0 comments on commit eec0efc

Please sign in to comment.