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

WIP: Talker entity implementation #75

Draft
wants to merge 9 commits into
base: dev
Choose a base branch
from
3 changes: 3 additions & 0 deletions .clang-format
Expand Up @@ -24,6 +24,8 @@ AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortLambdasOnASingleLine: Empty
AllowAllArgumentsOnNextLine: true

AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
Expand All @@ -50,6 +52,7 @@ BraceWrapping:
SplitEmptyRecord: true
SplitEmptyNamespace: true
BeforeLambdaBody: true
AfterCaseLabel: true

BreakBeforeBinaryOperators: NonAssignment
BreakBeforeTernaryOperators: false
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -11,3 +11,5 @@
/externals/3rdparty/winpcap/Include
/externals/3rdparty/winpcap/Lib

.idea/
cmake-build-debug/
30 changes: 30 additions & 0 deletions CONTRIBUTING.md
Expand Up @@ -11,3 +11,33 @@ Read and follow the coding style and guidelines [from this file](CODING_STYLE_GU
- Don't forget to update any impacted CHANGELOG file(s)
- Run the *fix_files.sh* script
- Start a github pull request

## To run `fix_files.sh` on MAC

* Update `bash` from 3.x to latest (5.x)

The following commands will alter default system shell for the current user to freshly installed bash.

```bash
brew install bash
echo "/usr/local/bin/bash" | sudo tee -a /etc/shells
chsh -s /usr/local/bin/bash
```

You can revert to any shell, listed by

```bash
cat /etc/shells
```

including default system `/bin/bash` or `/bin/zsh` with the following command

```bash
chsh -s <your preferred shell>
```

* Install latest `clang-format` (11.x)

```bash
brew install romansavrulin/clang-format/clang-format-lambda --HEAD
```
3 changes: 2 additions & 1 deletion examples/src/discovery.cpp
Expand Up @@ -147,7 +147,8 @@ void Discovery::onEntityOnline(la::avdecc::controller::Controller const* const /
auto const& obj = objIt.second;
if (obj.staticModel->memoryObjectType == la::avdecc::entity::model::MemoryObjectType::PngEntity)
{
_controller->readDeviceMemory(entity->getEntity().getEntityID(), obj.staticModel->startAddress, obj.staticModel->maximumLength,
_controller->readDeviceMemory(
entity->getEntity().getEntityID(), obj.staticModel->startAddress, obj.staticModel->maximumLength,
[](la::avdecc::controller::ControlledEntity const* const /*entity*/, float const percentComplete)
{
outputText("Memory Object progress: " + std::to_string(percentComplete) + "\n");
Expand Down
21 changes: 19 additions & 2 deletions examples/src/utils.cpp
Expand Up @@ -34,6 +34,18 @@ static SCREEN* s_Screen = nullptr;
# include <iostream>
#endif // USE_CURSES

int getUserChoice()
{
#if defined(USE_CURSES)
if (s_Window == nullptr)
return 0;
int c = wgetch(s_Window);
#else
int c = getch();
#endif
c -= '0';
return c;
}

void initOutput()
{
Expand Down Expand Up @@ -114,7 +126,7 @@ la::avdecc::protocol::ProtocolInterface::Type chooseProtocolInterfaceType(la::av
int index = -1;
while (index == -1)
{
int c = getch() - '0';
auto c = getUserChoice();
if (c >= 1 && c <= static_cast<int>(protocolInterfaceTypes.count()))
{
index = c - 1;
Expand Down Expand Up @@ -146,6 +158,11 @@ la::avdecc::networkInterface::Interface chooseNetworkInterface()
return {};
}

if (interfaces.size() == 1)
{
return interfaces.at(0);
}

// Let the user choose an interface
outputText("Choose an interface:\n");
unsigned int intNum = 1;
Expand All @@ -160,7 +177,7 @@ la::avdecc::networkInterface::Interface chooseNetworkInterface()
int index = -1;
while (index == -1)
{
int c = getch() - '0';
auto c = getUserChoice();
if (c >= 1 && c <= static_cast<int>(interfaces.size()))
{
index = c - 1;
Expand Down
1 change: 1 addition & 0 deletions include/la/avdecc/avdecc.hpp
Expand Up @@ -50,6 +50,7 @@

/** Controller entity type definition */
#include "internals/controllerEntity.hpp"
#include "internals/talkerEntity.hpp"

/** Symbols export definition */
#include "internals/exports.hpp"
Expand Down
3 changes: 2 additions & 1 deletion include/la/avdecc/internals/aggregateEntity.hpp
Expand Up @@ -31,6 +31,7 @@
#include "entityModel.hpp"
#include "entityAddressAccessTypes.hpp"
#include "controllerEntity.hpp"
#include "talkerEntity.hpp"
#include "exports.hpp"

#include <thread>
Expand Down Expand Up @@ -77,7 +78,7 @@ class AggregateEntity : public LocalEntity, public controller::Interface

virtual void setControllerDelegate(controller::Delegate* const delegate) noexcept = 0;
//virtual void setListenerDelegate(listener::Delegate* const delegate) noexcept = 0;
//virtual void setTalkerDelegate(talker::Delegate* const delegate) noexcept = 0;
virtual void setTalkerDelegate(talker::Delegate* const delegate) noexcept = 0;

// Deleted compiler auto-generated methods
AggregateEntity(AggregateEntity&&) = delete;
Expand Down
1 change: 1 addition & 0 deletions include/la/avdecc/internals/endStation.hpp
Expand Up @@ -27,6 +27,7 @@

#include "entity.hpp"
#include "controllerEntity.hpp"
#include "talkerEntity.hpp"
#include "aggregateEntity.hpp"
#include "protocolInterface.hpp"
#include "exports.hpp"
Expand Down
474 changes: 474 additions & 0 deletions include/la/avdecc/internals/talkerEntity.hpp

Large diffs are not rendered by default.