Initial source commit

This change contains the initial source for the framework.
This is a work in progress, but should compile and produce
both .deb and .rpm packages (with proper system support).

Currently the support is for RMR based messaging only.

The examples are rough but provide a first cut demonstration
of the base framework.

Issue-ID: RIC-148

Signed-off-by: E. Scott Daniels <daniels@research.att.com>
Change-Id: I9c64aa7db20c2977a4422d7257077e2531cc67d5
diff --git a/src/xapp/CMakeLists.txt b/src/xapp/CMakeLists.txt
new file mode 100644
index 0000000..093ef6f
--- /dev/null
+++ b/src/xapp/CMakeLists.txt
@@ -0,0 +1,40 @@
+# vim: sw=4 ts=4 noet:
+#
+#==================================================================================
+#   Copyright (c) 2020 Nokia
+#   Copyright (c) 2020 AT&T Intellectual Property.
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#==================================================================================
+#
+
+
+# For clarity: this generates object, not a lib as the CM command implies.
+#
+add_library( xapp_objects OBJECT
+	xapp.cpp  	
+)
+
+target_include_directories (xapp_objects PUBLIC
+	$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
+	$<INSTALL_INTERFACE:include>
+	PRIVATE src)
+
+# header files should go into .../include/xfcpp/
+if( DEV_PKG )
+	install( FILES
+		xapp.hpp  
+		DESTINATION ${install_inc}
+	) 
+endif()
+
diff --git a/src/xapp/README b/src/xapp/README
new file mode 100644
index 0000000..39391b2
--- /dev/null
+++ b/src/xapp/README
@@ -0,0 +1,27 @@
+
+==================================================================================
+       Copyright (c) 2020 Nokia
+       Copyright (c) 2020 AT&T Intellectual Property.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================================
+
+This directory contains the source for the overall Xapp class.
+Specifially:
+
+	xapp.*
+		Is the class that the user creates in their application. It provides, by
+		extension, the RMR messaging functions.
+
+
+	
diff --git a/src/xapp/xapp.cpp b/src/xapp/xapp.cpp
new file mode 100644
index 0000000..02cea30
--- /dev/null
+++ b/src/xapp/xapp.cpp
@@ -0,0 +1,99 @@
+// vi: ts=4 sw=4 noet:
+/*
+==================================================================================
+	Copyright (c) 2020 Nokia
+	Copyright (c) 2020 AT&T Intellectual Property.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================================
+*/
+
+/*
+	Mnemonic:	xapp.cpp
+	Abstract:	The main xapp class.
+				This class actually extends the messenger class as most of what
+				would be done here is just passing through to the messenger.
+
+	Date:		13 March 2020
+	Author:		E. Scott Daniels
+*/
+
+#include <string.h>
+#include <unistd.h>
+
+#include <rmr/rmr.h>
+#include <rmr/RIC_message_types.h>
+
+
+#include <iostream>
+#include <thread>
+
+#include <messenger.hpp>
+#include "xapp.hpp"
+
+// --------------- private -----------------------------------------------------
+
+
+
+// --------------- builders -----------------------------------------------
+
+/*
+	If wait4table is true, then the construction of the object does not
+	complete until the underlying transport has a new copy of the route
+	table.
+
+	If port is nil, then the default port is used (4560).
+*/
+Xapp::Xapp( char* port, bool wait4table ) : Messenger( port, wait4table ) {
+	// what's left to do?
+}
+
+/*
+	Destroyer.
+*/
+Xapp::~Xapp() {
+	// nothing to destroy; superclass destruction is magically invoked.
+}
+
+/*
+	Start n threads, each running a listener which will drive callbacks.
+
+	The final listener is started in the main thread; in otherwords this
+	function won't return unless that listener crashes.
+*/
+void Xapp::Run( int nthreads ) {
+	int joined;						// at end, number of threads joined back
+	int i;
+	std::thread** tinfo;				// each thread we'll start
+
+	tinfo = new std::thread* [nthreads-1];
+
+	for( i = 0; i < nthreads - 1; i++ ) {				// thread for each n-1; last runs here
+		tinfo[i] = new std::thread( &Xapp::Listen, this );
+	}
+
+	this->Listen();						// will return only when halted
+
+	for( i = 0; i < nthreads - 1; i++ ) {				// wait for others to stop
+		tinfo[i]->join();
+	}
+}
+
+/*
+	Halt the xapp. This will drive the messenger's stop function to prevent any
+	active listeners from running, and will shut things down.
+*/
+void Xapp::Halt() {
+	this->Stop();			// messenger shut off
+}
+
diff --git a/src/xapp/xapp.hpp b/src/xapp/xapp.hpp
new file mode 100644
index 0000000..a3d5e97
--- /dev/null
+++ b/src/xapp/xapp.hpp
@@ -0,0 +1,59 @@
+// vi: ts=4 sw=4 noet:
+/*
+==================================================================================
+	Copyright (c) 2020 Nokia
+	Copyright (c) 2020 AT&T Intellectual Property.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================================
+*/
+
+/*
+	Mnemonic:	xapp.hpp
+	Abstract:	Headers for the xapp class. This class extends the messenger class
+				as most of the function of this class would be just passing through
+				calls to the messenger object.
+
+	Date:		13 March 2020
+	Author:		E. Scott Daniels
+*/
+
+#ifndef _xapp_hpp
+#define _xapp_hpp
+
+
+#include <iostream>
+#include <string>
+#include <mutex>
+#include <map>
+
+#include <rmr/rmr.h>
+
+#include "callback.hpp"
+#include "messenger.hpp"
+
+class Xapp : public Messenger {
+
+	private:
+		std::string name;
+
+	public:
+		Xapp( char* listen_port, bool wait4rt );	// builder
+		Xapp( );
+		~Xapp();									// destroyer
+
+		void Run( int nthreads );					// message listen driver
+		void Halt( );								// force to stop
+};
+
+#endif