Skip to content

Commit

Permalink
duplicating changes from jdpipe/gs-netstream
Browse files Browse the repository at this point in the history
  • Loading branch information
jdpipe committed Nov 24, 2021
1 parent a2d20cf commit 4c166b8
Show file tree
Hide file tree
Showing 9 changed files with 428 additions and 462 deletions.
6 changes: 6 additions & 0 deletions graphstream/gs-netstream/c++/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
netstream-main
*.exe
*.dll
*.so
*.o
*.a
24 changes: 13 additions & 11 deletions graphstream/gs-netstream/c++/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,33 @@ OBJDIR=obj
SRCDIR=src
INCDIR=include

ifeq (darwin,$(findstring darwin,$(shell $(CC) -v 2>&1 | grep ^Target)))
ifeq ($(shell uname),Darwin)
AR=libtool
ARFLAGS=-static -o
else
AR=ar
ARFLAGS=rcs
endif

CC = g++
CWARN = -W -Wall -Wshadow -Wimplicit -Wreturn-type -Wcomment -Wtrigraphs -Wformat -Wparentheses -Wpointer-arith -Wuninitialized -O

CDBG = -g $(CWARN) -fno-inline
CFLAGS = -I$(INCDIR) -O3
DFLAGS = -I$(INCDIR) -g $(CWARN) -fno-inline -DDEBUG=1

ifeq (MINGW,$(findstring MINGW,$(shell uname)))
# https://stackoverflow.com/questions/714100/os-detecting-makefile
ifeq ($(OS),Windows_NT)
SOCKET_LIB = -lwsock32
else
SOCKET_LIB =
SOCKET_LIB =
endif


CTAG = ctags
CTAGFILE = filelist
# src, object and bin files
OUT_BINARY := netstream-main
OUT_BINARY := netstream-main
OUT_LIBRARY := libnetstream.a

HEADERS = $(INCDIR)/global.h
Expand All @@ -35,22 +38,22 @@ OBJS = \
$(OBJDIR)/netstream-storage.o \
$(OBJDIR)/netstream-socket.o \
$(OBJDIR)/netstream-sender.o \
$(OBJDIR)/netstream-main.o

$(OBJDIR)/netstream-main.o
.SECONDARY:

#-- Rules
all: $(OUT_BINARY) $(OUT_LIBRARY)

$(OUT_BINARY): $(OBJS)
$(CXX) $(CFLAGS) -I$(INCDIR) $(OBJS) -o $(OUT_BINARY) $(SOCKET_LIB)
$(CC) $(CFLAGS) $(OBJS) -o $(OUT_BINARY) $(SOCKET_LIB)

$(OUT_LIBRARY): $(OBJS)
$(AR) $(ARFLAGS) $(OUT_LIBRARY) $(OBJS)
$(AR) $(ARFLAGS) $(OUT_LIBRARY) $(OBJS)

$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
mkdir -p $(OBJDIR)
$(CXX) $(CFLAGS) -c $? -o $@
$(CC) $(CFLAGS) -c $? -o $@

.PHONY: clean depend fresh

Expand All @@ -64,8 +67,7 @@ clean:
-rm -f $(SRCDIR)/*.output $(LEX_C)
-rm -f */*~ *~ core
-rm -f $(BINDIR)/*
-rm -f $(OUT_BINARY) $(OUT_BINARY).exe
-rm -f $(OUT_BINARY)
-rm -f $(OUT_LIBRARY)
-rm -rf $(OBJDIR)

fresh: clean all
71 changes: 37 additions & 34 deletions graphstream/gs-netstream/c++/src/netstream-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

#include <iostream>
#include <sstream>

#include "netstream-sizes.h"
#include "netstream-storage.h"
#include "netstream-socket.h"
#include "netstream-constants.h"
Expand All @@ -38,7 +36,7 @@ int main (int argc, char const *argv[])

void e(){
string source_id="C++_netstream_test";
GS_LONG time_id=0L;
long time_id=0L;
NetStreamSender stream("default","localhost",2001,false);
string n1("node");
while(1) {
Expand All @@ -48,49 +46,55 @@ void e(){
}





void example(){
string source_id("C");
GS_LONG time_id = 0L;
string source_id("C++_netstream_test");
long time_id=0L;
NetStreamSender stream("default","localhost",2001,false);
string style("node{fill-mode:plain;fill-color:#567;size:6px;}");
stream.addGraphAttribute(source_id, time_id++, "stylesheet", style);
stream.addGraphAttribute(source_id, time_id++, "test", "test");
stream.changeGraphAttribute(source_id, time_id++, "test", "test",false);
stream.addGraphAttribute(source_id, time_id++, "ui.antialias", true);
stream.addGraphAttribute(source_id, time_id++, "layout.stabilization-limit", 0);
for (int i = 0; i < 10; i++) {
for (int i = 0; i < 500; i++) {
stringstream n1;
n1<<i;
stream.addNode(source_id, time_id++, n1.str());
stream.addNodeAttribute(source_id, time_id++, n1.str(), "ui.label", n1.str());
if (i > 0) {
stringstream n2;
n2<<(i-1);
stringstream n3;
n3<<(i/2);
stringstream e1;
e1<<n1.str()<<"-"<<n2.str();
stringstream e2;
e2<<n1.str()<<"-"<<n3.str();
//cout<<"edge :"<<e1.str()<<endl;
stream.addEdge(source_id, time_id++, e1.str(), n1.str(), n2.str(), false);
stream.addEdge(source_id, time_id++, e2.str(), n1.str(), n3.str(), false);
}
stream.addNode(source_id, time_id++, n1.str());
if (i > 0) {


stringstream n2;
n2<<(i-1);

stringstream n3;
n3<<(i/2);

stringstream e1;
e1<<n1.str()<<"-"<<n2.str();
stringstream e2;
e2<<n1.str()<<"-"<<n3.str();
//cout<<"edge :"<<e1.str()<<endl;
stream.addEdge(source_id, time_id++, e1.str(), n1.str(), n2.str(), false);
stream.addEdge(source_id, time_id++, e2.str(), n1.str(), n3.str(), false);
}
}
}

void types_test(){
string source_id="C++_netstream_test";
GS_LONG time_id=0L;
long time_id=0L;
NetStreamSender stream("default","localhost",2001,true);


stream.addGraphAttribute(source_id, time_id++, "int", (GS_INT)1);
stream.addGraphAttribute(source_id, time_id++, "float", (GS_FLOAT)1);
stream.addGraphAttribute(source_id, time_id++, "double", (GS_DOUBLE)1.0);
stream.addGraphAttribute(source_id, time_id++, "long", (GS_LONG)1);
stream.addGraphAttribute(source_id, time_id++, "byte", (GS_CHAR)0);
stream.addGraphAttribute(source_id, time_id++, "boolean", (GS_BOOL)true);
stream.addGraphAttribute(source_id, time_id++, "int", 1);
stream.addGraphAttribute(source_id, time_id++, "float", (float)1);
stream.addGraphAttribute(source_id, time_id++, "double", 1.0);
stream.addGraphAttribute(source_id, time_id++, "long", 1L);
stream.addGraphAttribute(source_id, time_id++, "byte", (char) 0);
stream.addGraphAttribute(source_id, time_id++, "boolean", true);

int v[] = {1776,7,4};
vector<int> value(v,v+3);
Expand All @@ -104,12 +108,12 @@ void types_test(){
vector<double> value3(v3,v3+2);
stream.addGraphAttribute(source_id, time_id++, "doubleArray", value3);

GS_LONG v4[] = {1776,7,4};
vector<GS_LONG> value4(v4,v4+3);
long int v4[] = {1776,7,4};
vector<long int> value4(v4,v4+3);
stream.addGraphAttribute(source_id, time_id++, "longArray", value4);

GS_CHAR v5[] = {'0',(GS_CHAR)0,'z'};
vector<GS_CHAR> value5(v5,v5+3);
char v5[] = {'0',(char)0,'z'};
vector<char> value5(v5,v5+3);
stream.addGraphAttribute(source_id, time_id++, "byteArray",value5 );

bool v6[] = {true,false};
Expand All @@ -121,10 +125,9 @@ void types_test(){

void events_test(){
string source_id="C++_netstream_test";
GS_LONG time_id = 0L;
long time_id=0L;
NetStreamSender stream("localhost", 2001);
stream.addNode(source_id, time_id++, "node0");
stream.addNode(source_id, time_id++, "node1");
stream.addEdge(source_id, time_id++, "edge", "node0", "node1", true);
stream.addNodeAttribute(source_id, time_id++, "node0","nodeAttribute", 0);
stream.changeNodeAttribute(source_id, time_id++, "node0","nodeAttribute",0, 1);
Expand Down
Loading

0 comments on commit 4c166b8

Please sign in to comment.