Skip to content

Commit 16f4d42

Browse files
committed
Merge pull request #98 from christiankerl/refactor_data_received_callback
moved DataReceivedCallback from TransferPool to separate header
2 parents f9ef12c + 70766a2 commit 16f4d42

File tree

6 files changed

+55
-15
lines changed

6 files changed

+55
-15
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* This file is part of the OpenKinect Project. http://www.openkinect.org
3+
*
4+
* Copyright (c) 2014 individual OpenKinect contributors. See the CONTRIB file
5+
* for details.
6+
*
7+
* This code is licensed to you under the terms of the Apache License, version
8+
* 2.0, or, at your option, the terms of the GNU General Public License,
9+
* version 2.0. See the APACHE20 and GPL2 files for the text of the licenses,
10+
* or the following URLs:
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
* http://www.gnu.org/licenses/gpl-2.0.txt
13+
*
14+
* If you redistribute this file in source form, modified or unmodified, you
15+
* may:
16+
* 1) Leave this header intact and distribute it under the same terms,
17+
* accompanying it with the APACHE20 and GPL20 files, or
18+
* 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or
19+
* 3) Delete the GPL v2 clause and accompany it with the APACHE20 file
20+
* In all cases you must keep the copyright notice intact and include a copy
21+
* of the CONTRIB file.
22+
*
23+
* Binary distributions must follow the binary distribution requirements of
24+
* either License.
25+
*/
26+
27+
28+
#ifndef DATA_CALLBACK_H_
29+
#define DATA_CALLBACK_H_
30+
31+
#include <stddef.h>
32+
33+
namespace libfreenect2
34+
{
35+
36+
class DataCallback
37+
{
38+
public:
39+
virtual void onDataReceived(unsigned char *buffer, size_t n) = 0;
40+
};
41+
42+
} // namespace libfreenect2
43+
44+
#endif // DATA_CALLBACK_H_

examples/protonect/include/libfreenect2/depth_packet_stream_parser.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include <libfreenect2/double_buffer.h>
3434
#include <libfreenect2/depth_packet_processor.h>
3535

36-
#include <libfreenect2/usb/transfer_pool.h>
36+
#include <libfreenect2/data_callback.h>
3737

3838
#include <libfreenect2/common.h>
3939

@@ -51,7 +51,7 @@ PACK(struct DepthSubPacketFooter
5151
uint32_t fields[32];
5252
});
5353

54-
class DepthPacketStreamParser : public libfreenect2::usb::TransferPool::DataReceivedCallback
54+
class DepthPacketStreamParser : public DataCallback
5555
{
5656
public:
5757
DepthPacketStreamParser();

examples/protonect/include/libfreenect2/packet_pipeline.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#ifndef PACKET_PIPELINE_H_
2828
#define PACKET_PIPELINE_H_
2929

30-
#include <libfreenect2/usb/transfer_pool.h>
30+
#include <libfreenect2/data_callback.h>
3131
#include <libfreenect2/rgb_packet_stream_parser.h>
3232
#include <libfreenect2/depth_packet_stream_parser.h>
3333
#include <libfreenect2/depth_packet_processor.h>
@@ -39,7 +39,7 @@ namespace libfreenect2
3939
class PacketPipeline
4040
{
4141
public:
42-
typedef libfreenect2::usb::TransferPool::DataReceivedCallback PacketParser;
42+
typedef DataCallback PacketParser;
4343
virtual ~PacketPipeline();
4444

4545
virtual PacketParser *getRgbPacketParser() const = 0;

examples/protonect/include/libfreenect2/rgb_packet_stream_parser.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
#include <libfreenect2/double_buffer.h>
3333
#include <libfreenect2/rgb_packet_processor.h>
3434

35-
#include <libfreenect2/usb/transfer_pool.h>
35+
#include <libfreenect2/data_callback.h>
3636

3737
namespace libfreenect2
3838
{
3939

40-
class RgbPacketStreamParser : public libfreenect2::usb::TransferPool::DataReceivedCallback
40+
class RgbPacketStreamParser : public DataCallback
4141
{
4242
public:
4343
RgbPacketStreamParser();

examples/protonect/include/libfreenect2/usb/transfer_pool.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@
2727
#ifndef TRANSFER_POOL_H_
2828
#define TRANSFER_POOL_H_
2929

30+
#include <deque>
3031
#include <libusb.h>
3132

32-
#include <deque>
33+
#include <libfreenect2/data_callback.h>
3334

3435
namespace libfreenect2
3536
{
@@ -40,11 +41,6 @@ namespace usb
4041
class TransferPool
4142
{
4243
public:
43-
struct DataReceivedCallback
44-
{
45-
virtual void onDataReceived(unsigned char *buffer, size_t n) = 0;
46-
};
47-
4844
TransferPool(libusb_device_handle *device_handle, unsigned char device_endpoint);
4945
virtual ~TransferPool();
5046

@@ -58,7 +54,7 @@ class TransferPool
5854

5955
void cancel();
6056

61-
void setCallback(DataReceivedCallback *callback);
57+
void setCallback(DataCallback *callback);
6258
protected:
6359
void allocateTransfers(size_t num_transfers, size_t transfer_size);
6460

@@ -67,7 +63,7 @@ class TransferPool
6763

6864
virtual void processTransfer(libusb_transfer *transfer) = 0;
6965

70-
DataReceivedCallback *callback_;
66+
DataCallback *callback_;
7167
private:
7268
typedef std::deque<libusb_transfer *> TransferQueue;
7369

examples/protonect/src/transfer_pool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void TransferPool::cancel()
122122
//idle_transfers_.insert(idle_transfers_.end(), pending_transfers_.begin(), pending_transfers_.end());
123123
}
124124

125-
void TransferPool::setCallback(TransferPool::DataReceivedCallback *callback)
125+
void TransferPool::setCallback(DataCallback *callback)
126126
{
127127
callback_ = callback;
128128
}

0 commit comments

Comments
 (0)