mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
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:
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* ClientConnectionAdapter.h
|
||||
*
|
||||
* Created on: Nov 2, 2012
|
||||
* Author: Mitchell Wills
|
||||
*/
|
||||
|
||||
#ifndef CLIENTCONNECTIONADAPTER_H_
|
||||
#define CLIENTCONNECTIONADAPTER_H_
|
||||
|
||||
class ClientConnectionAdapter;
|
||||
|
||||
#include "networktables2/connection/ConnectionAdapter.h"
|
||||
#include "networktables2/IncomingEntryReceiver.h"
|
||||
#include "networktables2/FlushableOutgoingEntryReceiver.h"
|
||||
#include "networktables2/client/ClientNetworkTableEntryStore.h"
|
||||
#include "networktables2/stream/IOStreamFactory.h"
|
||||
#include "networktables2/thread/NTThreadManager.h"
|
||||
#include "networktables2/thread/NTThread.h"
|
||||
#include "networktables2/client/ClientConnectionState.h"
|
||||
#include "networktables2/client/ClientConnectionListenerManager.h"
|
||||
#include "networktables2/connection/ConnectionMonitorThread.h"
|
||||
|
||||
|
||||
/**
|
||||
* Object that adapts messages from a server
|
||||
*
|
||||
* @author Mitchell
|
||||
*
|
||||
*/
|
||||
class ClientConnectionAdapter : public ConnectionAdapter, public IncomingEntryReceiver, public FlushableOutgoingEntryReceiver{
|
||||
private:
|
||||
ClientNetworkTableEntryStore& entryStore;
|
||||
IOStreamFactory& streamFactory;
|
||||
NTThreadManager& threadManager;
|
||||
|
||||
ClientConnectionState* connectionState;
|
||||
ClientConnectionListenerManager& connectionListenerManager;
|
||||
NTReentrantSemaphore LOCK;
|
||||
NetworkTableEntryTypeManager& typeManager;
|
||||
NTThread* readThread;
|
||||
ConnectionMonitorThread* monitor;
|
||||
NetworkTableConnection* connection;
|
||||
|
||||
void gotoState(ClientConnectionState* newState);
|
||||
bool m_IsConnectionClosed; //Keep track of when this is closed to issue reconnect
|
||||
public:
|
||||
/**
|
||||
* @return the state of the connection
|
||||
*/
|
||||
ClientConnectionState* getConnectionState();
|
||||
/**
|
||||
* @return if the client is connected to the server
|
||||
*/
|
||||
bool isConnected();
|
||||
|
||||
/**
|
||||
* Create a new ClientConnectionAdapter
|
||||
* @param entryStore
|
||||
* @param threadManager
|
||||
* @param streamFactory
|
||||
* @param transactionPool
|
||||
* @param connectionListenerManager
|
||||
*/
|
||||
ClientConnectionAdapter(ClientNetworkTableEntryStore& entryStore, NTThreadManager& threadManager, IOStreamFactory& streamFactory, ClientConnectionListenerManager& connectionListenerManager, NetworkTableEntryTypeManager& typeManager);
|
||||
virtual ~ClientConnectionAdapter();
|
||||
|
||||
|
||||
/*
|
||||
* Connection management
|
||||
*/
|
||||
/**
|
||||
* Reconnect the client to the server (even if the client is not currently connected)
|
||||
*/
|
||||
void reconnect();
|
||||
|
||||
/**
|
||||
* Close the client connection
|
||||
*/
|
||||
void close();
|
||||
/**
|
||||
* Close the connection to the server and enter the given state
|
||||
* @param newState
|
||||
*/
|
||||
void close(ClientConnectionState* newState);
|
||||
|
||||
|
||||
|
||||
void badMessage(BadMessageException& e);
|
||||
|
||||
void ioException(IOException& e);
|
||||
|
||||
NetworkTableEntry* GetEntry(EntryId id);
|
||||
|
||||
|
||||
bool keepAlive();
|
||||
|
||||
void clientHello(ProtocolVersion protocolRevision);
|
||||
|
||||
void protocolVersionUnsupported(ProtocolVersion protocolRevision);
|
||||
|
||||
void serverHelloComplete();
|
||||
|
||||
|
||||
void offerIncomingAssignment(NetworkTableEntry* entry);
|
||||
void offerIncomingUpdate(NetworkTableEntry* entry, SequenceNumber sequenceNumber, EntryValue value);
|
||||
|
||||
void offerOutgoingAssignment(NetworkTableEntry* entry);
|
||||
|
||||
void offerOutgoingUpdate(NetworkTableEntry* entry);
|
||||
void flush();
|
||||
void ensureAlive();
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* CLIENTCONNECTIONADAPTER_H_ */
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* ClientConnectionListenerManager.h
|
||||
*
|
||||
* Created on: Sep 24, 2012
|
||||
* Author: Mitchell Wills
|
||||
*/
|
||||
|
||||
#ifndef CLIENTCONNECTIONLISTENERMANAGER_H_
|
||||
#define CLIENTCONNECTIONLISTENERMANAGER_H_
|
||||
|
||||
/**
|
||||
* An object that manages connection listeners and fires events for other listeners
|
||||
*
|
||||
* @author Mitchell
|
||||
*
|
||||
*/
|
||||
class ClientConnectionListenerManager
|
||||
{
|
||||
public:
|
||||
virtual ~ClientConnectionListenerManager()
|
||||
{
|
||||
}
|
||||
/**
|
||||
* called when something is connected
|
||||
*/
|
||||
virtual void FireConnectedEvent() = 0;
|
||||
/**
|
||||
* called when something is disconnected
|
||||
*/
|
||||
virtual void FireDisconnectedEvent() = 0;
|
||||
};
|
||||
|
||||
#endif /* CLIENTCONNECTIONLISTENERMANAGER_H_ */
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* ClientConnectionState.h
|
||||
*
|
||||
* Created on: Nov 2, 2012
|
||||
* Author: Mitchell Wills
|
||||
*/
|
||||
|
||||
#ifndef CLIENTCONNECTIONSTATE_H_
|
||||
#define CLIENTCONNECTIONSTATE_H_
|
||||
|
||||
|
||||
class ClientConnectionState;
|
||||
class ClientConnectionState_Error;
|
||||
class ClientConnectionState_ProtocolUnsuppotedByServer;
|
||||
|
||||
#include <exception>
|
||||
#include "networktables2/connection/NetworkTableConnection.h"
|
||||
|
||||
/**
|
||||
* Represents a state that the client is in
|
||||
*
|
||||
* @author Mitchell
|
||||
*
|
||||
*/
|
||||
class ClientConnectionState {
|
||||
public:
|
||||
/**
|
||||
* indicates that the client is disconnected from the server
|
||||
*/
|
||||
static ClientConnectionState DISCONNECTED_FROM_SERVER;
|
||||
/**
|
||||
* indicates that the client is connected to the server but has not yet begun communication
|
||||
*/
|
||||
static ClientConnectionState CONNECTED_TO_SERVER;
|
||||
/**
|
||||
* represents that the client has sent the hello to the server and is waiting for a response
|
||||
*/
|
||||
static ClientConnectionState SENT_HELLO_TO_SERVER;
|
||||
/**
|
||||
* represents that the client is now in sync with the server
|
||||
*/
|
||||
static ClientConnectionState IN_SYNC_WITH_SERVER;
|
||||
|
||||
|
||||
private:
|
||||
const char* name;
|
||||
protected:
|
||||
ClientConnectionState(const char* name);
|
||||
public:
|
||||
virtual const char* toString();
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Represents that a client received a message from the server indicating that the client's protocol revision is not supported by the server
|
||||
* @author Mitchell
|
||||
*
|
||||
*/
|
||||
class ClientConnectionState_ProtocolUnsuppotedByServer : public ClientConnectionState{
|
||||
private:
|
||||
const ProtocolVersion serverVersion;
|
||||
public:
|
||||
/**
|
||||
* Create a new protocol unsupported state
|
||||
* @param serverVersion
|
||||
*/
|
||||
ClientConnectionState_ProtocolUnsuppotedByServer(ProtocolVersion serverVersion);
|
||||
/**
|
||||
* @return the protocol version that the server reported it supports
|
||||
*/
|
||||
ProtocolVersion getServerVersion();
|
||||
const char* toString();
|
||||
};
|
||||
/**
|
||||
* Represents that the client is in an error state
|
||||
*
|
||||
* @author Mitchell
|
||||
*
|
||||
*/
|
||||
class ClientConnectionState_Error : public ClientConnectionState{
|
||||
private:
|
||||
std::exception& e;
|
||||
char msg[100];
|
||||
public:
|
||||
/**
|
||||
* Create a new error state
|
||||
* @param e
|
||||
*/
|
||||
ClientConnectionState_Error(std::exception& e);
|
||||
/**
|
||||
* @return the exception that caused the client to enter an error state
|
||||
*/
|
||||
std::exception& getException();
|
||||
virtual const char* toString();
|
||||
};
|
||||
|
||||
|
||||
#endif /* CLIENTCONNECTIONSTATE_H_ */
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* ClientNetworkTableEntryStore.h
|
||||
*
|
||||
* Created on: Nov 2, 2012
|
||||
* Author: Mitchell Wills
|
||||
*/
|
||||
|
||||
#ifndef CLIENTNETWORKTABLEENTRYSTORE_H_
|
||||
#define CLIENTNETWORKTABLEENTRYSTORE_H_
|
||||
|
||||
|
||||
class ClientNetworkTableEntryStore;
|
||||
|
||||
|
||||
#include "networktables2/AbstractNetworkTableEntryStore.h"
|
||||
#include "networktables2/NetworkTableEntry.h"
|
||||
#include "OSAL/Synchronized.h"
|
||||
|
||||
/**
|
||||
* The entry store for a {@link NetworkTableClient}
|
||||
*
|
||||
* @author Mitchell
|
||||
*
|
||||
*/
|
||||
class ClientNetworkTableEntryStore : public AbstractNetworkTableEntryStore{
|
||||
|
||||
public:
|
||||
/**
|
||||
* Create a new ClientNetworkTableEntryStore
|
||||
* @param transactionPool
|
||||
* @param listenerManager
|
||||
*/
|
||||
ClientNetworkTableEntryStore(TableListenerManager& listenerManager);
|
||||
virtual ~ClientNetworkTableEntryStore();
|
||||
|
||||
protected:
|
||||
bool addEntry(NetworkTableEntry* newEntry);
|
||||
bool updateEntry(NetworkTableEntry* entry, SequenceNumber sequenceNumber, EntryValue value);
|
||||
|
||||
public:
|
||||
/**
|
||||
* Send all unknown entries in the entry store to the given connection
|
||||
* @param connection
|
||||
* @throws IOException
|
||||
*/
|
||||
void sendUnknownEntries(NetworkTableConnection& connection);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* CLIENTNETWORKTABLEENTRYSTORE_H_ */
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* NetworkTableClient.h
|
||||
*
|
||||
* Created on: Nov 3, 2012
|
||||
* Author: Mitchell Wills
|
||||
*/
|
||||
|
||||
#ifndef NETWORKTABLECLIENT_H_
|
||||
#define NETWORKTABLECLIENT_H_
|
||||
|
||||
class NetworkTableClient;
|
||||
|
||||
#include "networktables2/NetworkTableNode.h"
|
||||
#include "networktables2/client/ClientConnectionAdapter.h"
|
||||
#include "networktables2/WriteManager.h"
|
||||
#include "networktables2/TransactionDirtier.h"
|
||||
|
||||
/**
|
||||
* A client node in NetworkTables 2.0
|
||||
*
|
||||
* @author Mitchell
|
||||
*
|
||||
*/
|
||||
class NetworkTableClient : public NetworkTableNode{
|
||||
private:
|
||||
ClientConnectionAdapter& adapter;
|
||||
WriteManager& writeManager;
|
||||
TransactionDirtier* dirtier;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Create a new NetworkTable Client
|
||||
* @param streamFactory
|
||||
* @param threadManager
|
||||
* @param transactionPool
|
||||
*/
|
||||
NetworkTableClient(IOStreamFactory& streamFactory, NetworkTableEntryTypeManager& typeManager, NTThreadManager& threadManager);
|
||||
~NetworkTableClient();
|
||||
|
||||
/**
|
||||
* force the client to disconnect and reconnect to the server again. Will connect if the client is currently disconnected
|
||||
*/
|
||||
void reconnect();
|
||||
|
||||
void Close();
|
||||
|
||||
void stop();
|
||||
|
||||
bool IsConnected();
|
||||
|
||||
bool IsServer();
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* NETWORKTABLECLIENT_H_ */
|
||||
Reference in New Issue
Block a user