From df044930bca4252ff6e4814c654a612c6aee2136 Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Wed, 20 Nov 2019 12:45:16 -0500 Subject: [0.1.7 REWRITE] Codebase overhaul. ~ Codebase split into two sub-packages ~ net.transit.network for transfering between objects ~ net.transit.type for type registering and conversion + Added new interfaces (INode and ISystem) + More documentation + (Kinda) Working build - Removed unnessairy interfaces (IGenerator and IConsumer) - Removed base types ~ Restructured type system --- .../net/transit/network/packet/ArrayPacket.java | 45 ++++++++++++++++++++++ .../java/net/transit/network/packet/IPacket.java | 23 +++++++++++ .../net/transit/network/packet/MetaPacket.java | 33 ++++++++++++++++ .../net/transit/network/packet/StaticPacket.java | 25 ++++++++++++ 4 files changed, 126 insertions(+) create mode 100644 src/main/java/net/transit/network/packet/ArrayPacket.java create mode 100644 src/main/java/net/transit/network/packet/IPacket.java create mode 100644 src/main/java/net/transit/network/packet/MetaPacket.java create mode 100644 src/main/java/net/transit/network/packet/StaticPacket.java (limited to 'src/main/java/net/transit/network/packet') diff --git a/src/main/java/net/transit/network/packet/ArrayPacket.java b/src/main/java/net/transit/network/packet/ArrayPacket.java new file mode 100644 index 0000000..9cbd300 --- /dev/null +++ b/src/main/java/net/transit/network/packet/ArrayPacket.java @@ -0,0 +1,45 @@ +package net.transit.network.packet; + +import java.util.ArrayList; + +import net.transit.type.Type; + +public class ArrayPacket implements IPacket +{ + private ArrayList arrayData; + private Type type; + + public ArrayPacket(D startValue, Type t) + { + arrayData = new ArrayList(0); + arrayData.add(startValue); + } + + public D getData() + { + if(arrayData.size() > 0) return arrayData.get(0); + return null; + } + + public void addData(D data) + { + arrayData.add(data); + } + + public D popAndShift() + { + D temp = null; + + if(arrayData.size() > 0) + { + temp = arrayData.remove(0); + } + + return temp; + } + + @Override + public Type getType() { + return type; + } +} \ No newline at end of file diff --git a/src/main/java/net/transit/network/packet/IPacket.java b/src/main/java/net/transit/network/packet/IPacket.java new file mode 100644 index 0000000..deafdf8 --- /dev/null +++ b/src/main/java/net/transit/network/packet/IPacket.java @@ -0,0 +1,23 @@ +package net.transit.network.packet; + +import net.transit.type.Type; + +/** + * @author Kyle Gunger + * + * @param The data type (Object) that the packet transfers. + */ +public interface IPacket +{ + /**Get the packet's data + * + * @return The packet's data + */ + public D getData(); + + /**Get the packet's type + * + * @return IType<> The type of the packet + */ + public Type getType(); +} \ No newline at end of file diff --git a/src/main/java/net/transit/network/packet/MetaPacket.java b/src/main/java/net/transit/network/packet/MetaPacket.java new file mode 100644 index 0000000..e4cffdf --- /dev/null +++ b/src/main/java/net/transit/network/packet/MetaPacket.java @@ -0,0 +1,33 @@ +package net.transit.network.packet; + +import net.transit.type.Type; + +public class MetaPacket implements IPacket +{ + + private D data; + private M metaData; + private Type type; + + public MetaPacket(D dat, Type t, M meta) + { + data = dat; + type = t; + metaData = meta; + } + + public D getData() + { + return data; + } + + public M getMetaData() + { + return metaData; + } + + @Override + public Type getType() { + return type; + } +} diff --git a/src/main/java/net/transit/network/packet/StaticPacket.java b/src/main/java/net/transit/network/packet/StaticPacket.java new file mode 100644 index 0000000..8399041 --- /dev/null +++ b/src/main/java/net/transit/network/packet/StaticPacket.java @@ -0,0 +1,25 @@ +package net.transit.network.packet; + +import net.transit.type.Type; + +public class StaticPacket implements IPacket +{ + private D data; + private Type type; + + public StaticPacket(D dat, Type t) + { + data = dat; + type = t; + } + + public D getData() + { + return data; + } + + @Override + public Type getType() { + return type; + } +} \ No newline at end of file -- cgit v1.2.3