Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ntcore] Various cleanups #7216

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
239a2ea
[ntcore] LocalStorage: Move template functions inside class definition
PeterJohnson Oct 15, 2024
30a997e
[ntcore] Value: Inline constructors
PeterJohnson Oct 15, 2024
40dfc53
[ntcore] NetworkOutgoingQueue: Move function defs inside class
PeterJohnson Oct 15, 2024
79c1281
[ntcore] Move ServerImpl to nt::server namespace
PeterJohnson Oct 16, 2024
a48c529
[ntcore] Move ServerImpl detail classes to separate files
PeterJohnson Oct 16, 2024
38330d3
[ntcore] Move ServerImpl.m_local to ServerClientLocal
PeterJohnson Oct 16, 2024
05328c1
[ntcore] Store client name instead of pointer in server pub/sub
PeterJohnson Oct 16, 2024
a144257
[ntcore] Make server publisher and subscriber classes
PeterJohnson Oct 16, 2024
e754518
[ntcore] Server: remove unused m_controlReady
PeterJohnson Oct 16, 2024
8afbfa0
[ntcore] Split ServerStorage out from ServerImpl
PeterJohnson Oct 17, 2024
e854fe1
[ntcore] ServerImpl: Move some creation to ServerClient4
PeterJohnson Oct 17, 2024
f05d085
[ntcore] ServerImpl: Refactor getting empty client slot
PeterJohnson Oct 17, 2024
c6f51be
[ntcore] ServerImpl: Inlining
PeterJohnson Oct 17, 2024
b7a2b0f
[ntcore] Move metatopic creation from SetLocal to constructor
PeterJohnson Oct 17, 2024
1649fcc
Clean up some forward declarations
PeterJohnson Oct 17, 2024
1f27801
[ntcore] Split LocalStorage implementation into separate files
PeterJohnson Oct 19, 2024
089beb8
[ntcore] LocalStorage: Change GetEntry to return Entry
PeterJohnson Oct 19, 2024
ae79c61
[ntcore] LocalStorage: Rename classes to Local*
PeterJohnson Oct 19, 2024
de32b98
[ntcore] LocalStorageImpl: Replace WPI_ERROR with ERR
PeterJohnson Oct 19, 2024
eaeaefc
[ntcore] HandleMap: Use concepts for T
PeterJohnson Oct 19, 2024
9447516
[ntcore] Refactor local topic DataLog
PeterJohnson Oct 19, 2024
5d97014
[ntcore] Move properties and flags refresh to LocalTopic
PeterJohnson Oct 19, 2024
891e800
[ntcore] Further refactor of topic datalog
PeterJohnson Oct 19, 2024
70467be
[ntcore] Local topic: Refactor flags
PeterJohnson Oct 20, 2024
3e0868c
[ntcore] Local topic: A bit more properties refactor
PeterJohnson Oct 20, 2024
9c29645
[ntcore] Start working on dedicated server mode
PeterJohnson Oct 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ntcore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ file(
GLOB ntcore_native_src
src/main/native/cpp/*.cpp
src/generated/main/native/cpp/*.cpp
src/main/native/cpp/local/*.cpp
src/main/native/cpp/net/*.cpp
src/main/native/cpp/net3/*.cpp
src/main/native/cpp/networktables/*.cpp
src/main/native/cpp/server/*.cpp
src/main/native/cpp/tables/*.cpp
)
add_library(ntcore ${ntcore_native_src})
Expand Down
8 changes: 7 additions & 1 deletion ntcore/src/main/native/cpp/HandleMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#pragma once

#include <concepts>
#include <memory>
#include <utility>

Expand All @@ -13,8 +14,13 @@

namespace nt {

template <typename T>
concept HandleType = requires {
{ T::kType } -> std::convertible_to<NT_Handle>;
};

// Utility wrapper class for our UidVectors
template <typename T, size_t Size>
template <HandleType T, size_t Size>
class HandleMap : public wpi::UidVector<std::unique_ptr<T>, Size> {
public:
template <typename... Args>
Expand Down
8 changes: 5 additions & 3 deletions ntcore/src/main/native/cpp/InstanceImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,20 @@ void InstanceImpl::StopLocal() {

void InstanceImpl::StartServer(std::string_view persistFilename,
std::string_view listenAddress,
unsigned int port3, unsigned int port4) {
unsigned int port3, unsigned int port4,
bool dedicated) {
std::scoped_lock lock{m_mutex};
if (networkMode != NT_NET_MODE_NONE) {
return;
}
m_networkServer = std::make_shared<NetworkServer>(
persistFilename, listenAddress, port3, port4, localStorage,
connectionList, logger, [this] {
connectionList, logger, dedicated, [this] {
std::scoped_lock lock{m_mutex};
networkMode &= ~NT_NET_MODE_STARTING;
});
networkMode = NT_NET_MODE_SERVER | NT_NET_MODE_STARTING;
networkMode = (dedicated ? NT_NET_MODE_SERVER_ONLY : NT_NET_MODE_SERVER) |
NT_NET_MODE_STARTING;
listenerStorage.NotifyTimeSync({}, NT_EVENT_TIMESYNC, 0, 0, true);
m_serverTimeOffset = 0;
m_rtt2 = 0;
Expand Down
2 changes: 1 addition & 1 deletion ntcore/src/main/native/cpp/InstanceImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class InstanceImpl {
void StopLocal();
void StartServer(std::string_view persistFilename,
std::string_view listenAddress, unsigned int port3,
unsigned int port4);
unsigned int port4, bool dedicated);
void StopServer();
void StartClient3(std::string_view identity);
void StartClient4(std::string_view identity);
Expand Down
Loading
Loading