CMake Changes

This is the changes made by Patrick Plenefisch converting the native
code to use CMake and the CMake Maven Plugin, as opposed to the
native Maven plugin. This is to allow for compatibility with newer
versions of the GCC toolchain. All the cpp sources were moved from
maven style directories to cpp style directories for CMake.

Change-Id: I67f5e3608948f37c83b0990d232105a3784f8593
This commit is contained in:
Brad Miller
2014-03-24 16:13:08 -04:00
parent 33134bef1d
commit 69d9ad70ab
804 changed files with 586 additions and 9377 deletions

View File

@@ -0,0 +1,67 @@
/*
* NetworkTableServer.h
*
* Created on: Sep 27, 2012
* Author: Mitchell Wills
*/
#ifndef NETWORKTABLESERVER_H_
#define NETWORKTABLESERVER_H_
class NetworkTableServer;
#include "networktables2/TransactionDirtier.h"
#include "networktables2/NetworkTableNode.h"
#include "networktables2/server/ServerIncomingStreamMonitor.h"
#include "networktables2/server/ServerIncomingConnectionListener.h"
#include "networktables2/WriteManager.h"
#include "networktables2/stream/IOStreamProvider.h"
#include "networktables2/server/ServerConnectionList.h"
/**
* A server node in NetworkTables 2.0
*
* @author Mitchell
*
*/
class NetworkTableServer : public NetworkTableNode, public ServerIncomingConnectionListener{
private:
IOStreamProvider& streamProvider;
ServerIncomingStreamMonitor incomingStreamMonitor;
ServerConnectionList connectionList;
WriteManager writeManager;
TransactionDirtier continuingReceiver;
public:
/**
* Create a NetworkTable Server
*
* @param streamProvider
* @param threadManager
* @param transactionPool
*/
NetworkTableServer(IOStreamProvider& streamProvider, NetworkTableEntryTypeManager& typeManager, NTThreadManager& threadManager);
~NetworkTableServer();
/**
* Create a NetworkTable Server
*
* @param streamProvider
*/
NetworkTableServer(IOStreamProvider& streamProvider);
void Close();
void OnNewConnection(ServerConnectionAdapter& connectionAdapter);
bool IsConnected();
bool IsServer();
};
#endif /* NETWORKTABLESERVER_H_ */

View File

@@ -0,0 +1,34 @@
/*
* ServerAdapterManager.h
*
* Created on: Sep 26, 2012
* Author: Mitchell Wills
*/
#ifndef SERVERADAPTERMANAGER_H_
#define SERVERADAPTERMANAGER_H_
class ServerAdapterManager;
#include "networktables2/server/ServerConnectionAdapter.h"
/**
* A class that manages connections to a server
*
* @author Mitchell
*
*/
class ServerAdapterManager
{
public:
virtual ~ServerAdapterManager()
{
}
/**
* Called when a connection adapter has been closed
* @param connectionAdapter the adapter that was closed
*/
virtual void close(ServerConnectionAdapter& connectionAdapter, bool closeStream) = 0;
};
#endif /* SERVERADAPTERMANAGER_H_ */

View File

@@ -0,0 +1,102 @@
/*
* ServerConnectionAdapter.h
*
* Created on: Sep 26, 2012
* Author: Mitchell Wills
*/
#ifndef SERVERCONNECTIONADAPTER_H_
#define SERVERCONNECTIONADAPTER_H_
class ServerConnectionAdapter;
#include "networktables2/connection/ConnectionMonitorThread.h"
#include "networktables2/NetworkTableEntry.h"
#include "networktables2/connection/ConnectionAdapter.h"
#include "networktables2/stream/IOStream.h"
#include "networktables2/IncomingEntryReceiver.h"
#include "networktables2/FlushableOutgoingEntryReceiver.h"
#include "networktables2/server/ServerNetworkTableEntryStore.h"
#include "networktables2/server/ServerAdapterManager.h"
#include "networktables2/server/ServerConnectionState.h"
#include "networktables2/thread/NTThread.h"
#include "networktables2/thread/NTThreadManager.h"
/**
* Object that adapts messages from a client to the server
*
* @author Mitchell
*
*/
class ServerConnectionAdapter : public ConnectionAdapter, public IncomingEntryReceiver, public FlushableOutgoingEntryReceiver{
private:
ServerNetworkTableEntryStore& entryStore;
IncomingEntryReceiver& transactionReceiver;
ServerAdapterManager& adapterListener;
public:
/**
* the connection this adapter uses
*/
NetworkTableConnection connection;
private:
NTThread* readThread;
ConnectionMonitorThread monitorThread;
private:
ServerConnectionState* connectionState;
void gotoState(ServerConnectionState* newState);
bool m_IsAdapterListenerClosed;
public:
/**
* Create a server connection adapter for a given stream
*
* @param stream
* @param transactionPool
* @param entryStore
* @param transactionReceiver
* @param adapterListener
* @param threadManager
*/
ServerConnectionAdapter(IOStream* stream, ServerNetworkTableEntryStore& entryStore, IncomingEntryReceiver& transactionReceiver, ServerAdapterManager& adapterListener, NetworkTableEntryTypeManager& typeManager, NTThreadManager& threadManager);
virtual ~ServerConnectionAdapter();
/**
* stop the read thread and close the stream
*/
void shutdown(bool closeStream);
void offerOutgoingAssignment(NetworkTableEntry* entry);
void offerOutgoingUpdate(NetworkTableEntry* entry);
void flush();
/**
* @return the state of the connection
*/
ServerConnectionState* getConnectionState();
void ensureAlive();
//return true once the close has been issued
bool IsAdapterListenerClosed() const {return m_IsAdapterListenerClosed;}
ConnectionAdapter &AsConnectionAdapter() {return *this;}
protected: //from ConnectionAdapter
bool keepAlive();
void badMessage(BadMessageException& e);
void ioException(IOException& e);
void clientHello(ProtocolVersion protocolRevision);
void protocolVersionUnsupported(ProtocolVersion protocolRevision);
void serverHelloComplete();
void offerIncomingAssignment(NetworkTableEntry* entry);
void offerIncomingUpdate(NetworkTableEntry* entry, SequenceNumber sequenceNumber, EntryValue value);
NetworkTableEntry* GetEntry(EntryId id);
};
#endif /* SERVERCONNECTIONADAPTER_H_ */

View File

@@ -0,0 +1,59 @@
/*
* ServerConnectionList.h
*
* Created on: Sep 26, 2012
* Author: Mitchell Wills
*/
#ifndef SERVERCONNECTIONLIST_H_
#define SERVERCONNECTIONLIST_H_
class ServerConnectionList;
class ServerIncomingStreamMonitor;
#include "networktables2/FlushableOutgoingEntryReceiver.h"
#include "networktables2/NetworkTableEntry.h"
#include "networktables2/server/ServerAdapterManager.h"
#include "networktables2/server/ServerConnectionAdapter.h"
#include <vector>
/**
* A list of connections that the server currently has
*
* @author Mitchell
*
*/
class ServerConnectionList : public FlushableOutgoingEntryReceiver, public ServerAdapterManager{
private:
NTReentrantSemaphore connectionsLock;
std::vector<ServerConnectionAdapter*> connections;
ServerIncomingStreamMonitor * const m_Factory; //make call to close connection
public:
ServerConnectionList(ServerIncomingStreamMonitor *Factory);
virtual ~ServerConnectionList();
/**
* Add a connection to the list
* @param connection
*/
void add(ServerConnectionAdapter& connection);
void close(ServerConnectionAdapter& connectionAdapter, bool closeStream);
/**
* close all connections and remove them
*/
void closeAll();
void offerOutgoingAssignment(NetworkTableEntry* entry);
void offerOutgoingUpdate(NetworkTableEntry* entry);
void flush();
void ensureAlive();
};
#endif /* SERVERCONNECTIONLIST_H_ */

View File

@@ -0,0 +1,75 @@
/*
* ServerConnectionState.h
*
* Created on: Sep 26, 2012
* Author: Mitchell Wills
*/
#ifndef SERVERCONNECTIONSTATE_H_
#define SERVERCONNECTIONSTATE_H_
class ServerConnectionState;
class ServerConnectionState_Error;
#include <exception>
/**
* Represents the state of a connection to the server
*
* @author Mitchell
*
*/
class ServerConnectionState
{
public:
/**
* represents that the server has received the connection from the client but has not yet received the client hello
*/
static ServerConnectionState GOT_CONNECTION_FROM_CLIENT;
/**
* represents that the client is in a connected non-error state
*/
static ServerConnectionState CONNECTED_TO_CLIENT;
/**
* represents that the client has disconnected from the server
*/
static ServerConnectionState CLIENT_DISCONNECTED;
private:
const char* name;
protected:
ServerConnectionState(const char* name);
public:
virtual const char* toString();
virtual ~ServerConnectionState()
{
}
};
/**
* Represents that the client is in an error state
*
* @author Mitchell
*
*/
class ServerConnectionState_Error : public ServerConnectionState
{
private:
std::exception& e;
public:
/**
* Create a new error state
* @param e
*/
ServerConnectionState_Error(std::exception& e);
virtual const char* toString();
/**
* @return the exception that caused the client connection to enter an error state
*/
std::exception& getException();
};
#endif /* SERVERCONNECTIONSTATE_H_ */

View File

@@ -0,0 +1,32 @@
/*
* ServerIncomingConnectionListener.h
*
* Created on: Sep 26, 2012
* Author: Mitchell Wills
*/
#ifndef SERVERINCOMINGCONNECTIONLISTENER_H_
#define SERVERINCOMINGCONNECTIONLISTENER_H_
#include "networktables2/server/ServerConnectionAdapter.h"
/**
* Listener for new incoming server connections
* @author Mitchell
*
*/
class ServerIncomingConnectionListener
{
public:
virtual ~ServerIncomingConnectionListener()
{
}
/**
*
* Called on create of a new connection
* @param connectionAdapter the server connection adapter
*/
virtual void OnNewConnection(ServerConnectionAdapter& connectionAdapter) = 0;
};
#endif /* SERVERINCOMINGCONNECTIONLISTENER_H_ */

View File

@@ -0,0 +1,79 @@
/*
* ServerIncomingStreamMonitor.h
*
* Created on: Sep 26, 2012
* Author: Mitchell Wills
*/
#ifndef SERVERINCOMINGSTREAMMONITOR_H_
#define SERVERINCOMINGSTREAMMONITOR_H_
class ServerIncomingStreamMonitor;
#include "networktables2/thread/PeriodicRunnable.h"
#include "networktables2/thread/NTThreadManager.h"
#include "networktables2/thread/NTThread.h"
#include "networktables2/stream/IOStreamProvider.h"
#include "networktables2/server/ServerIncomingConnectionListener.h"
#include "networktables2/server/ServerNetworkTableEntryStore.h"
#include "networktables2/server/ServerAdapterManager.h"
#include "networktables2/server/ServerConnectionAdapter.h"
/**
* Thread that monitors for incoming connections
*
* @author Mitchell
*
*/
class ServerIncomingStreamMonitor : PeriodicRunnable{
private:
IOStreamProvider& streamProvider;
ServerNetworkTableEntryStore& entryStore;
ServerIncomingConnectionListener& incomingListener;
ServerAdapterManager& adapterListener;
NetworkTableEntryTypeManager& typeManager;
NTThreadManager& threadManager;
NTThread* monitorThread;
NTReentrantSemaphore BlockDeletionList;
std::vector<ServerConnectionAdapter *> m_DeletionList;
public:
/**
* Create a new incoming stream monitor
* @param streamProvider the stream provider to retrieve streams from
* @param entryStore the entry store for the server
* @param transactionPool transaction pool for the server
* @param incomingListener the listener that is notified of new connections
* @param adapterListener the listener that will listen to adapter events
* @param threadManager the thread manager used to create the incoming thread and provided to the Connection Adapters
*/
ServerIncomingStreamMonitor(IOStreamProvider& streamProvider, ServerNetworkTableEntryStore& entryStore,
ServerIncomingConnectionListener& incomingListener,
ServerAdapterManager& adapterListener,
NetworkTableEntryTypeManager& typeManager, NTThreadManager& threadManager);
~ServerIncomingStreamMonitor();
/**
* Start the monitor thread
*/
void start();
/**
* Stop the monitor thread
*/
void stop();
void run();
void close(ServerConnectionAdapter *Adapter);
};
#endif /* SERVERINCOMINGSTREAMMONITOR_H_ */

View File

@@ -0,0 +1,55 @@
/*
* ServerNetworkTableEntryStore.h
*
* Created on: Sep 26, 2012
* Author: Mitchell Wills
*/
#ifndef SERVERNETWORKTABLEENTRYSTORE_H_
#define SERVERNETWORKTABLEENTRYSTORE_H_
class ServerNetworkTableEntryStore;
#include "networktables2/AbstractNetworkTableEntryStore.h"
#include "networktables2/NetworkTableEntry.h"
#include "OSAL/Synchronized.h"
/**
* The entry store for a {@link NetworkTableServer}
*
* @author Mitchell
*
*/
class ServerNetworkTableEntryStore : public AbstractNetworkTableEntryStore{
private:
EntryId nextId;
public:
/**
* Create a new Server entry store
* @param transactionPool the transaction pool
* @param listenerManager the listener manager that fires events from this entry store
*/
ServerNetworkTableEntryStore(TableListenerManager& listenerManager);
virtual ~ServerNetworkTableEntryStore();
protected:
bool addEntry(NetworkTableEntry* newEntry);
bool updateEntry(NetworkTableEntry* entry, SequenceNumber sequenceNumber, EntryValue value);
public:
/**
* Send all entries in the entry store as entry assignments in a single transaction
* @param connection
* @throws IOException
*/
void sendServerHello(NetworkTableConnection& connection);
};
#endif /* SERVERNETWORKTABLEENTRYSTORE_H_ */