Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
neilstephens committed Jan 9, 2024
1 parent 9579d6a commit 725a69c
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 81 deletions.
22 changes: 0 additions & 22 deletions src/ProtoConv/FrameChecker.cpp

This file was deleted.

7 changes: 2 additions & 5 deletions src/ProtoConv/FrameChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,11 @@

#include <asio.hpp>

typedef asio::basic_streambuf<std::allocator<char>> buf_t;
using buf_t = asio::basic_streambuf<std::allocator<char>>;

class FrameChecker
struct FrameChecker
{
public:
FrameChecker();
virtual ~FrameChecker() = default;

virtual size_t CheckFrame(const buf_t& readbuf) = 0;
};

Expand Down
37 changes: 0 additions & 37 deletions src/ProtoConv/NullFrameChecker.cpp

This file was deleted.

21 changes: 8 additions & 13 deletions src/ProtoConv/NullFrameChecker.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/* opendatacon
/* MiniPlex
*
* Copyright (c) 2014:
*
* DCrip3fJguWgVCLrZFfA7sIGgvx1Ou3fHfCxnrz4svAi
* yxeOtDhDCXf1Z4ApgXvX5ahqQmzRfJ2DoX8S05SqHA==
* Copyright (c) 2023: Neil Stephens
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,12 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* NullFrameChecker.h
*
* Created on: 18/12/2023
* Author: Neil Stephens
*/

#ifndef NULLFRAMECHECKER_H
#define NULLFRAMECHECKER_H

Expand All @@ -31,8 +23,11 @@
class NullFrameChecker : public FrameChecker
{
public:
NullFrameChecker();
size_t CheckFrame(const buf_t& readbuf) override;
inline size_t CheckFrame(const buf_t& readbuf) override
{
//Don't check anything. Everything is a valid 'frame'.
return readbuf.size();
}
};

#endif // NULLFRAMECHECKER_H
4 changes: 2 additions & 2 deletions src/ProtoConv/ProtoConv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ void ProtoConv::RcvStreamHandler(buf_t& buf)
// The C++20 way causes a malloc error when asio tries to copy a handler with this style shared_ptr
//auto pForwardBuf = std::make_shared<uint8_t[]>(n);
// Use the old way instead - only difference should be the control block is allocated separately
auto pForwardBuf = std::shared_ptr<char>(new char[frame_len],[](char* p){delete[] p;});
const size_t ncopied = buf.sgetn(pForwardBuf.get(),frame_len);
auto pForwardBuf = std::shared_ptr<uint8_t>(new uint8_t[frame_len],[](uint8_t* p){delete[] p;});
const size_t ncopied = buf.sgetn(reinterpret_cast<char*>(pForwardBuf.get()),frame_len);
if(ncopied != frame_len)
{
spdlog::get("ProtoConv")->warn("RcvStreamHandler(): Failed to copy whole frame to datagram buffer. Frame size {}, copied {}.",frame_len,ncopied);
Expand Down
2 changes: 1 addition & 1 deletion src/ProtoConv/ProtoConv.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <memory>
#include <deque>

typedef asio::basic_streambuf<std::allocator<char>> buf_t;
using buf_t = asio::basic_streambuf<std::allocator<char>>;

struct CmdArgs;

Expand Down
2 changes: 1 addition & 1 deletion src/ProtoConv/TCPSocketManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ inline std::string GetHandlerID()
return std::to_string(thread_id)+":"+std::to_string(++thread_handler_id);
}

typedef asio::basic_streambuf<std::allocator<char>> buf_t;
using buf_t = asio::basic_streambuf<std::allocator<char>>;

//buffer to track a data container
class shared_const_buffer: public asio::const_buffer
Expand Down

0 comments on commit 725a69c

Please sign in to comment.