Permalink
Browse files

ZeroBuf

  • Loading branch information...
kvart2006 committed Feb 19, 2017
1 parent 479f529 commit 2e03bd08559605cf369e355dd64dc9a1099c7343
View
@@ -47,6 +47,8 @@ env:
- PACKAGE=openjdk8
- PACKAGE=ovs
- PACKAGE=zeromq
+ - PACKAGE=servus
+ - PACKAGE=zerobuf
notifications:
irc:
View
@@ -0,0 +1,33 @@
+include ../Makefile.inc
+
+#Address:https://github.com/HBPVIS/Servus.git
+UPSTREAM=https://github.com/HBPVIS/Servus.git
+
+all: bin/servus
+
+bin/servus: Servus/build/servus
+ #Copying files to pkgs directory
+ (cd Servus/servus && ../../../pkgs/include/servus/. && cd ../../ \
+ cd Servus/build && \
+ cp lib/*.a ../../../pkgs/lib/. && \
+ cp -a include/servus ../../../pkgs/include/servus)
+
+Servus/build/servus: Servus/build/Makefile
+ $(MAKE) -C Servus/build
+
+Servus/build/Makefile: build/CMakeLists.txt
+ (mkdir -p Servus/build && \
+ cd Servus/build && \
+ cmake -DCMAKE_TOOLCHAIN_FILE=$(RUMPRUN_CMAKE_TOOLCHAIN_FILE) \
+ -DENABLE_XSLT=off \
+ -Wno-dev \
+ ..)
+
+build/CMakeLists.txt:
+ (git clone $(UPSTREAM))
+
+.PHONY: clean
+clean:
+ $(MAKE) -C Servus/build clean
+distclean: clean
+ rm -rf Servus
View
@@ -0,0 +1,14 @@
+# Overview
+
+This is servus library for rumprun, a small C++ network utility library that provides a zeroconf API, URI parsing, and 128 bit UUIDs [HBPVIS/Servus](https://github.com/HBPVIS/Servus). The test platform is running Ubuntu 16.04 and the compilation options include ```-std=c++17```.
+
+## Maintainer
+
+* Bela Berde, bela.berde@gmail.com
+* Github: @kvart2006
+
+## Instructions
+Use the included``Makefile`` by typing ```make```.
+
+## Note
+Servus is used by ZeroBuf [HBPVIS/ZeroBuf](https://github.com/HBPVIS/ZeroBuf).
Submodule Servus added at 36180b
View
@@ -0,0 +1,33 @@
+include ../Makefile.inc
+
+#Address:https://github.com/HBPVIS/ZeroBuf.git
+UPSTREAM=https://github.com/HBPVIS/ZeroBuf.git
+
+all: bin/zerobuf
+
+bin/zerobuf: ZeroBuf/build/zerobuf
+ #Copying files to pkgs directory
+ (cd ZeroBuf/zerobuf && ../../../pkgs/include/zerobuf/. && cd ../../ \
+ cd ZeroBuf/build && \
+ cp lib/*.a ../../../pkgs/lib/. && \
+ cp -a include/zerobuf ../../../pkgs/include/zerobuf)
+
+ZeroBuf/build/zerobuf: ZeroBuf/build/Makefile
+ $(MAKE) -C ZeroBuf/build
+
+ZeroBuf/build/Makefile: build/CMakeLists.txt
+ (mkdir -p ZeroBuf/build && \
+ cd ZeroBuf/build && \
+ cmake -DCMAKE_TOOLCHAIN_FILE=$(RUMPRUN_CMAKE_TOOLCHAIN_FILE) \
+ -DENABLE_XSLT=off \
+ -Wno-dev \
+ ..)
+
+build/CMakeLists.txt:
+ (git clone $(UPSTREAM))
+
+.PHONY: clean
+clean:
+ $(MAKE) -C ZeroBuf/build clean
+distclean: clean
+ rm -rf ZeroBuf
View
@@ -0,0 +1,93 @@
+# Overview
+
+This is zerobuf 0.5 for rumprun, a zero-copy, zero-serialize, zero-hassle protocol buffers [HBPVIS/ZeroBuf](https://github.com/HBPVIS/ZeroBuf). Zerobuf requires Servus [HBPVIS/Servus](https://github.com/HBPVIS/Servus).
+The test platform is running Ubuntu 16.04 and the compilation options include ```-std=c++17```.
+
+## Maintainer
+
+* Bela Berde, bela.berde@gmail.com
+* Github: @kvart2006
+
+## Instructions
+Use the included``Makefile`` by typing ```make```.
+
+## Examples
+
+The schema compiler, ```zerobufCxx.py```, is located in
+```/path_to/rumprun-packages/zerobuf/ZeroBuf/bin/```.
+
+To compile a schema file, called in this case ```aschema.fbs```, type:
+```/path_to/rumprun-packages/zerobuf/ZeroBuf/bin/zerobufCxx.py -o=. aschema.fbs```.
+
+Example1: ```/root/git/rumprun-packages/zerobuf/ZeroBuf/bin/zerobufCxx.py -o=. schema1.fbs.fbs```:
+
+In order to run an example application on rumprun, you have to provide the paths to the zerobuf include directory located in rumprun-packages/pkgs/include, and to the ```libServus``` and ```libZeroBuf``` libraries during compilation. Both are located in rumprun-packages/pkgs/lib:
+
+```
+$ x86_64-rumprun-netbsd-gcc <filename> -I <path-to-zeromq-package>/include \
+-L <path-to-zeromq-package>/lib -lpthread -lServus -lZeroBuf -o <filename-output>
+```
+Example (for testing schema1.fbs):
+Rumprun compile step:
+```
+<path-to-zeromq-package>/lib = /root/git/rumprun-packages/pkgs/lib
+<path-to-zeromq-package>/include = /root/git/rumprun-packages/pkgs/include
+```
+leads to:
+```
+x86_64-rumprun-netbsd-g++ -std=c++17 schema1_test.cpp schema1.cpp \
+/root/git/rumprun-packages/zerobuf/ZeroBuf/Servus/servus/serializable.cpp \
+-I/root/git/rumprun-packages/servus/Servus/servus \
+-I/root/git/rumprun-packages/zerobuf/ZeroBuf/zerobuf \
+-I/root/git/rumprun-packages/pkgs/include/zerobuf \
+-I/root/git/rumprun-packages/pkgs/include/servus \
+-I/root/git/rumprun-packages/pkgs/include \
+-L/root/git/rumprun-packages/pkgs/lib \
+-lpthread -lServus -lZeroBuf -o schema1-rr
+```
+Rumprun baking step:
+```
+rumprun-bake hw_generic schema1-rr.bin schema1-rr
+```
+Rumprun running step:
+```
+rumprun qemu -i schema1-rr.bin
+```
+
+### Example 1 - schema1
+A simple key-value record:
+```
+table KeyValue {
+ intvalue: int;
+ doublevalue: double;
+}
+```
+
+
+### Example 2 - schema2
+A record for 125 double:
+```
+table DoubleTable {
+ doublearray: [double:125];
+}
+
+```
+Use the following for compiling the example2:
+```
+x86_64-rumprun-netbsd-g++ -std=c++17 schema2_test.cpp schema2.cpp \
+/root/git/rumprun-packages/zerobuf/ZeroBuf/Servus/servus/serializable.cpp \
+-I/root/git/rumprun-packages/servus/Servus/servus \
+-I/root/git/rumprun-packages/zerobuf/ZeroBuf/zerobuf \
+-I/root/git/rumprun-packages/pkgs/include/zerobuf \
+-I/root/git/rumprun-packages/pkgs/include/servus \
+-I/root/git/rumprun-packages/pkgs/include \
+-L/root/git/rumprun-packages/pkgs/lib \
+-lpthread -lServus -lZeroBuf -o schema2-rr
+```
+and for baking the example2:
+```
+rumprun-bake hw_generic schema2-rr.bin schema2-rr
+```
+Finally, the Rumprun running step:
+```
+rumprun qemu -i schema2-rr.bin
Submodule ZeroBuf added at cea033
View
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,117 @@
+// Generated by zerobufCxx.py
+
+#include "schema1.h"
+
+#include <zerobuf/NonMovingAllocator.h>
+#include <zerobuf/NonMovingSubAllocator.h>
+#include <zerobuf/StaticSubAllocator.h>
+#include <zerobuf/json.h>
+
+
+int32_t KeyValue::getIntvalue() const
+{
+ return getAllocator().template getItem< int32_t >( 4 );
+}
+
+void KeyValue::setIntvalue( int32_t value )
+{
+ getAllocator().template getItem< int32_t >( 4 ) = value;
+ notifyChanged();
+}
+
+double KeyValue::getDoublevalue() const
+{
+ return getAllocator().template getItem< double >( 8 );
+}
+
+void KeyValue::setDoublevalue( double value )
+{
+ getAllocator().template getItem< double >( 8 ) = value;
+ notifyChanged();
+}
+
+KeyValue::KeyValue()
+ : KeyValue( ::zerobuf::AllocatorPtr( new ::zerobuf::NonMovingAllocator( 16, 0 )))
+{}
+
+KeyValue::KeyValue( const int32_t& intvalueValue, const double& doublevalueValue )
+ : KeyValue( ::zerobuf::AllocatorPtr( new ::zerobuf::NonMovingAllocator( 16, 0 )))
+{
+ setIntvalue( intvalueValue );
+ setDoublevalue( doublevalueValue );
+}
+
+KeyValue::KeyValue( const KeyValue& rhs )
+ : KeyValue( ::zerobuf::AllocatorPtr( new ::zerobuf::NonMovingAllocator( 16, 0 )))
+{
+ *this = rhs;
+}
+
+KeyValue::KeyValue( KeyValue&& rhs ) noexcept
+ : ::zerobuf::Zerobuf( std::move( rhs ))
+{
+}
+
+KeyValue::KeyValue( const ::zerobuf::Zerobuf& rhs )
+ : KeyValue( ::zerobuf::AllocatorPtr( new ::zerobuf::NonMovingAllocator( 16, 0 )))
+{
+ ::zerobuf::Zerobuf::operator = ( rhs );
+}
+
+KeyValue::KeyValue( ::zerobuf::AllocatorPtr allocator )
+ : ::zerobuf::Zerobuf( std::move( allocator ))
+{
+}
+
+KeyValue::~KeyValue()
+ {}
+
+KeyValue& KeyValue::operator = ( KeyValue&& rhs )
+{
+ ::zerobuf::Zerobuf::operator = ( std::move( rhs ));
+ return *this;
+}
+
+std::string KeyValue::getSchema() const
+{
+ return ZEROBUF_SCHEMA();
+}
+
+std::string KeyValue::ZEROBUF_SCHEMA()
+{
+ return R"({
+ "$schema": "http://json-schema.org/schema#",
+ "title": "KeyValue",
+ "description": "Class KeyValue of namespace []",
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "intvalue": {
+ "type": "integer"
+ },
+ "doublevalue": {
+ "type": "number"
+ }
+ }
+})";
+}
+
+void KeyValue::_parseJSON( const Json::Value& json )
+{
+ if( ::zerobuf::hasJSONField( json, "intvalue" ))
+ setIntvalue( int32_t( ::zerobuf::fromJSON< int32_t >( ::zerobuf::getJSONField( json, "intvalue" ))));
+ if( ::zerobuf::hasJSONField( json, "doublevalue" ))
+ setDoublevalue( double( ::zerobuf::fromJSON< double >( ::zerobuf::getJSONField( json, "doublevalue" ))));
+}
+
+void KeyValue::_createJSON( Json::Value& json ) const
+{
+ ::zerobuf::toJSON( int32_t( getIntvalue( )), ::zerobuf::getJSONField( json, "intvalue" ));
+ ::zerobuf::toJSON( double( getDoublevalue( )), ::zerobuf::getJSONField( json, "doublevalue" ));
+}
+
+namespace zerobuf
+{
+
+}
+
@@ -0,0 +1,5 @@
+
+table KeyValue {
+ intvalue: int;
+ doublevalue: double;
+}
View
@@ -0,0 +1,65 @@
+// Generated by zerobufCxx.py
+
+#pragma once
+#include <zerobuf/ConstAllocator.h> // static create
+#include <zerobuf/Vector.h> // member
+#include <zerobuf/Zerobuf.h> // base class
+#include <array> // member
+#include <memory> // std::unique_ptr
+
+
+class KeyValue;
+typedef std::unique_ptr< const KeyValue > ConstKeyValuePtr;
+
+class KeyValue : public ::zerobuf::Zerobuf
+{
+public:
+ int32_t getIntvalue() const;
+ /**
+ * Set the Intvalue value.
+ * notifyChanged() is internally called after the change has been done.
+ *
+ * @param value the Intvalue value
+ **/
+ void setIntvalue( int32_t value );
+
+ double getDoublevalue() const;
+ /**
+ * Set the Doublevalue value.
+ * notifyChanged() is internally called after the change has been done.
+ *
+ * @param value the Doublevalue value
+ **/
+ void setDoublevalue( double value );
+
+ KeyValue();
+ KeyValue( const int32_t& intvalueValue, const double& doublevalueValue );
+ KeyValue( const KeyValue& rhs );
+ KeyValue( KeyValue&& rhs ) noexcept;
+ KeyValue( const ::zerobuf::Zerobuf& rhs );
+ explicit KeyValue( ::zerobuf::AllocatorPtr allocator );
+ virtual ~KeyValue();
+ KeyValue& operator = ( const KeyValue& rhs ) { ::zerobuf::Zerobuf::operator = ( rhs ); return *this; }
+ KeyValue& operator = ( KeyValue&& rhs );
+
+ // Introspection
+ std::string getSchema() const final;
+ static std::string ZEROBUF_SCHEMA();
+ std::string getTypeName() const final { return "KeyValue"; }
+ static std::string ZEROBUF_TYPE_NAME() { return "KeyValue"; }
+ ::zerobuf::uint128_t getTypeIdentifier() const final { return ::zerobuf::uint128_t( 0xb4b0c39847a4b2dfull, 0x869b23418201dbf9ull ); }
+ static ::zerobuf::uint128_t ZEROBUF_TYPE_IDENTIFIER() { return ::zerobuf::uint128_t( 0xb4b0c39847a4b2dfull, 0x869b23418201dbf9ull ); }
+ size_t getZerobufStaticSize() const final { return 16; }
+ static size_t ZEROBUF_STATIC_SIZE() { return 16; }
+ size_t getZerobufNumDynamics() const final { return 0; }
+ static size_t ZEROBUF_NUM_DYNAMICS() { return 0; }
+ static ConstKeyValuePtr create( const void* data, const size_t size ) { return ConstKeyValuePtr( new KeyValue( ::zerobuf::AllocatorPtr( new ::zerobuf::ConstAllocator( reinterpret_cast< const uint8_t* >( data ), size )))); }
+
+ void _parseJSON( const Json::Value& json ) final;
+ void _createJSON( Json::Value& json ) const final;
+};
+
+namespace zerobuf
+{
+}
+
Oops, something went wrong.

0 comments on commit 2e03bd0

Please sign in to comment.