Implement independent instances.

Previously, most of the classes were implemented as singletons so only one
instance was possible.

This change adds an instance handle-based API.  In Java, this API is located
in a different package than the old API (edu.wpi.first.networktables).

Backwards compatibility with ITable and the old NetworkTable API is largely
maintained, but a handful of classes have moved to the new package in Java
(ConnectionInfo and PersistentException), and the old JNI has been completed
replaced.

Also:
- Move SetTeam implementation to Dispatcher.
- Consistently pass time through Java and C++ Value API.
- Rename nt_Value.h to NetworkTableValue.h for consistency with Java.
- Improve documentation
- Make C++ and Java APIs more consistent
- Document RPC functions and support RPC in Java.
- Add polling features for entry and connection listeners and use them to
  move callback threads to Java level.
- Remove thread start and stop hooks (as polling is available).
- Make Notifiers, RpcServer, Dispatcher, and Storage mockable.
- Set NOTIFY_NEW on immediate entry notifications.
- Make GetTable("/") and GetTable("") equivalent.
- Generate local notification for flags update when loading persistent file.

And many unit test updates/changes:
- Use InitGoogleMock instead of InitGoogleTest in test main.
- Move test printers to TestPrinter.h/cpp.
- Provide printers for StringRef, EntryNotifier, and Handle.
- StorageTest: Check notifications.
- Add entry notifier unit tests.
- Storage: Add test for incoming entry assignment.
- Update connection listener tests.
- Add entry listener unit tests.

Fixes #11, #140, #189, #190, #192, #193, #221
This commit is contained in:
Peter Johnson
2017-04-23 10:26:17 -07:00
parent 8125a179fb
commit 5ab20bb27c
118 changed files with 15638 additions and 4640 deletions

View File

@@ -8,38 +8,19 @@
#ifndef NT_LOG_H_
#define NT_LOG_H_
#include "support/atomic_static.h"
#include "support/Logger.h"
namespace nt {
class Logger : public wpi::Logger {
public:
static Logger& GetInstance() {
ATOMIC_STATIC(Logger, instance);
return instance;
}
~Logger();
private:
Logger();
ATOMIC_STATIC_DECL(Logger)
};
#define LOG(level, x) WPI_LOG(nt::Logger::GetInstance(), level, x)
#define LOG(level, x) WPI_LOG(m_logger, level, x)
#undef ERROR
#define ERROR(x) WPI_ERROR(nt::Logger::GetInstance(), x)
#define WARNING(x) WPI_WARNING(nt::Logger::GetInstance(), x)
#define INFO(x) WPI_INFO(nt::Logger::GetInstance(), x)
#define ERROR(x) WPI_ERROR(m_logger, x)
#define WARNING(x) WPI_WARNING(m_logger, x)
#define INFO(x) WPI_INFO(m_logger, x)
#define DEBUG(x) WPI_DEBUG(nt::Logger::GetInstance(), x)
#define DEBUG1(x) WPI_DEBUG1(nt::Logger::GetInstance(), x)
#define DEBUG2(x) WPI_DEBUG2(nt::Logger::GetInstance(), x)
#define DEBUG3(x) WPI_DEBUG3(nt::Logger::GetInstance(), x)
#define DEBUG4(x) WPI_DEBUG4(nt::Logger::GetInstance(), x)
} // namespace nt
#define DEBUG(x) WPI_DEBUG(m_logger, x)
#define DEBUG1(x) WPI_DEBUG1(m_logger, x)
#define DEBUG2(x) WPI_DEBUG2(m_logger, x)
#define DEBUG3(x) WPI_DEBUG3(m_logger, x)
#define DEBUG4(x) WPI_DEBUG4(m_logger, x)
#endif // NT_LOG_H_