Skip to content

Commit 2d4c13e

Browse files
committed
Merge branch 'master' into HEAD
2 parents 559a0b1 + 0589ec8 commit 2d4c13e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+442
-353
lines changed

CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required (VERSION 3.12)
22
project (liblsl
3-
VERSION 1.15
3+
VERSION 1.15.0
44
LANGUAGES C CXX
55
DESCRIPTION "Labstreaminglayer C/C++ library"
66
HOMEPAGE_URL "https://github.com/sccn/liblsl"
@@ -43,8 +43,6 @@ add_library(lslobj OBJECT
4343
src/cancellable_streambuf.h
4444
src/cancellation.h
4545
src/cancellation.cpp
46-
src/cast.h
47-
src/cast.cpp
4846
src/common.cpp
4947
src/common.h
5048
src/consumer_queue.cpp
@@ -54,8 +52,6 @@ add_library(lslobj OBJECT
5452
src/forward.h
5553
src/info_receiver.cpp
5654
src/info_receiver.h
57-
src/inireader.h
58-
src/inireader.cpp
5955
src/inlet_connection.cpp
6056
src/inlet_connection.h
6157
src/lsl_resolver_c.cpp
@@ -92,6 +88,11 @@ add_library(lslobj OBJECT
9288
src/time_receiver.h
9389
src/udp_server.cpp
9490
src/udp_server.h
91+
src/util/cast.hpp
92+
src/util/cast.cpp
93+
src/util/inireader.hpp
94+
src/util/inireader.cpp
95+
src/util/uuid.hpp
9596
thirdparty/loguru/loguru.cpp
9697
$<$<BOOL:${LSL_LEGACY_CPP_ABI}>:src/legacy/legacy_abi.cpp src/legacy/legacy_abi.h>
9798
# headers

examples/GetAllStreams.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* resolved and displayed. This is useful for browsing applications.
1111
*/
1212

13-
int main(int argc, char* argv[]) {
13+
int main(int argc, char *argv[]) {
1414
try {
1515
std::cout << "Here is a one-shot resolve of all current streams:" << std::endl;
1616

@@ -54,7 +54,7 @@ int main(int argc, char* argv[]) {
5454
std::this_thread::sleep_for(std::chrono::seconds(1));
5555
}
5656

57-
} catch (std::exception& e) { std::cerr << "Got an exception: " << e.what() << std::endl; }
57+
} catch (std::exception &e) { std::cerr << "Got an exception: " << e.what() << std::endl; }
5858
std::cout << "Press any key to exit. " << std::endl;
5959
std::cin.get();
6060
return 0;

examples/GetFullinfo.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
* resolve functions only includes the core information otherwise.
88
*/
99

10-
int main(int argc, char* argv[]) {
10+
int main(int argc, char *argv[]) {
1111
std::string field, value;
1212
if (argc != 3) {
1313
std::cout << "This connects to a stream which has a particular value for a given field and "
14-
"displays its full stream_info contentss."
15-
<< std::endl;
14+
"displays its full stream_info contentss."
15+
<< std::endl;
1616
std::cout << "Please enter a field name and the desired value (e.g. \"type EEG\" (without "
17-
"the quotes)):"
18-
<< std::endl;
17+
"the quotes)):"
18+
<< std::endl;
1919
std::cin >> field >> value;
2020
} else {
2121
field = argv[1];
@@ -36,11 +36,11 @@ int main(int argc, char* argv[]) {
3636

3737
// get & display the info
3838
std::cout << "The information about this stream is displayed in the following: "
39-
<< std::endl;
39+
<< std::endl;
4040
lsl::stream_info info = inlet.info();
4141
std::cout << info.as_xml() << std::endl;
4242

43-
} catch (std::exception& e) { std::cerr << "Got an exception: " << e.what() << std::endl; }
43+
} catch (std::exception &e) { std::cerr << "Got an exception: " << e.what() << std::endl; }
4444
std::cout << "Press any key to exit. " << std::endl;
4545
std::cin.get();
4646
return 0;

examples/GetTimeCorrection.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
* should be approx. 0 (up to some tolerance).
1010
*/
1111

12-
int main(int argc, char* argv[]) {
12+
int main(int argc, char *argv[]) {
1313
std::string field, value;
1414
if (argc != 3) {
1515
std::cout << "This connects to a stream which has a particular value for a given field and "
16-
"gets the time-synchronization information for it."
17-
<< std::endl;
16+
"gets the time-synchronization information for it."
17+
<< std::endl;
1818
std::cout << "Please enter a field name and the desired value (e.g. \"type EEG\" (without "
19-
"the quotes)):"
20-
<< std::endl;
19+
"the quotes)):"
20+
<< std::endl;
2121
std::cin >> field >> value;
2222
} else {
2323
field = argv[1];
@@ -38,13 +38,13 @@ int main(int argc, char* argv[]) {
3838

3939
// start receiving & displaying the data
4040
std::cout << "Press [Enter] to query a new correction value (clocks may drift)..."
41-
<< std::endl;
41+
<< std::endl;
4242
while (true) {
4343
std::cout << inlet.time_correction() << std::endl;
4444
std::cin.get();
4545
}
4646

47-
} catch (std::exception& e) { std::cerr << "Got an exception: " << e.what() << std::endl; }
47+
} catch (std::exception &e) { std::cerr << "Got an exception: " << e.what() << std::endl; }
4848
std::cout << "Press any key to exit. " << std::endl;
4949
std::cin.get();
5050
return 0;

examples/HandleMetaData.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
#include <iostream>
22
#include <lsl_cpp.h>
33

4-
int main(int argc, char* argv[]) {
4+
int main(int argc, char *argv[]) {
55
try {
66
// create a new stream_info and declare some meta-data (in accordance with XDF format)
7-
const char* name = argc > 1 ? argv[1] : "MetaTester";
7+
const char *name = argc > 1 ? argv[1] : "MetaTester";
88
lsl::stream_info info(name, "EEG", 8, 100, lsl::cf_float32, "myuid323457");
99
lsl::xml_element chns = info.desc().append_child("channels");
10-
const char* labels[] = {"C3", "C4", "Cz", "FPz", "POz", "CPz", "O1", "O2"};
11-
for (const char* label : labels)
10+
const char *labels[] = {"C3", "C4", "Cz", "FPz", "POz", "CPz", "O1", "O2"};
11+
for (const char *label : labels)
1212
chns.append_child("channel")
13-
.append_child_value("label", label)
14-
.append_child_value("unit", "microvolts")
15-
.append_child_value("type", "EEG");
13+
.append_child_value("label", label)
14+
.append_child_value("unit", "microvolts")
15+
.append_child_value("type", "EEG");
1616
info.desc().append_child_value("manufacturer", "SCCN");
1717
info.desc()
18-
.append_child("cap")
19-
.append_child_value("name", "EasyCap")
20-
.append_child_value("size", "54")
21-
.append_child_value("labelscheme", "10-20");
18+
.append_child("cap")
19+
.append_child_value("name", "EasyCap")
20+
.append_child_value("size", "54")
21+
.append_child_value("labelscheme", "10-20");
2222

2323
// create outlet for the stream
2424
lsl::stream_outlet outlet(info);
@@ -32,17 +32,17 @@ int main(int argc, char* argv[]) {
3232
// get the full stream info (including custom meta-data) and dissect it
3333
lsl::stream_info inf = inlet.info();
3434
std::cout << "The stream's XML meta-data is: \n"
35-
<< inf.as_xml()
36-
<< "\nThe manufacturer is: " << inf.desc().child_value("manufacturer")
37-
<< "\nThe cap circumference is: " << inf.desc().child("cap").child_value("size")
38-
<< "\nThe channel labels are as follows:\n";
35+
<< inf.as_xml()
36+
<< "\nThe manufacturer is: " << inf.desc().child_value("manufacturer")
37+
<< "\nThe cap circumference is: " << inf.desc().child("cap").child_value("size")
38+
<< "\nThe channel labels are as follows:\n";
3939
lsl::xml_element ch = inf.desc().child("channels").child("channel");
4040
for (int k = 0; k < info.channel_count(); k++) {
4141
std::cout << " " << ch.child_value("label") << std::endl;
4242
ch = ch.next_sibling();
4343
}
4444

45-
} catch (std::exception& e) { std::cerr << "Got an exception: " << e.what() << std::endl; }
45+
} catch (std::exception &e) { std::cerr << "Got an exception: " << e.what() << std::endl; }
4646
std::cout << "Press any key to exit. " << std::endl;
4747
std::cin.get();
4848
return 0;

examples/HandleMetaDataC.c

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,52 @@
11
#include <lsl_c.h>
22
#include <stdio.h>
33

4-
int main(int argc, char* argv[]) {
5-
int c; /* channel index */
6-
lsl_xml_ptr desc,chns,chn,cap; /* some xml element pointers */
7-
lsl_outlet outlet; /* stream outlet */
8-
lsl_streaminfo info,inf; /* streaminfo objects */
9-
lsl_inlet inlet; /* a stream inlet to get samples from */
10-
int errcode; /* error code (lsl_lost_error or timeouts) */
11-
const char* labels[] = {"C3","C4","Cz","FPz","POz","CPz","O1","O2"};
4+
int main(int argc, char *argv[]) {
5+
int c; /* channel index */
6+
lsl_xml_ptr desc, chns, chn, cap; /* some xml element pointers */
7+
lsl_outlet outlet; /* stream outlet */
8+
lsl_streaminfo info, inf; /* streaminfo objects */
9+
lsl_inlet inlet; /* a stream inlet to get samples from */
10+
int errcode; /* error code (lsl_lost_error or timeouts) */
11+
const char *labels[] = {"C3", "C4", "Cz", "FPz", "POz", "CPz", "O1", "O2"};
1212

1313
/* create a new streaminfo and declare some meta-data (in accordance with XDF format) */
14-
const char* name = argc > 1 ? argv[1] : "MetaTester";
15-
info = lsl_create_streaminfo(name,"EEG",8,100,cft_float32,"myuid323457");
14+
const char *name = argc > 1 ? argv[1] : "MetaTester";
15+
info = lsl_create_streaminfo(name, "EEG", 8, 100, cft_float32, "myuid323457");
1616
desc = lsl_get_desc(info);
17-
chns = lsl_append_child(desc,"channels");
18-
for (c=0;c<8;c++) {
19-
chn = lsl_append_child(chns,"channel");
20-
lsl_append_child_value(chn,"label",labels[c]);
21-
lsl_append_child_value(chn,"unit","microvolts");
22-
lsl_append_child_value(chn,"type","EEG");
17+
chns = lsl_append_child(desc, "channels");
18+
for (c = 0; c < 8; c++) {
19+
chn = lsl_append_child(chns, "channel");
20+
lsl_append_child_value(chn, "label", labels[c]);
21+
lsl_append_child_value(chn, "unit", "microvolts");
22+
lsl_append_child_value(chn, "type", "EEG");
2323
}
24-
lsl_append_child_value(desc,"manufacturer","SCCN");
25-
cap = lsl_append_child(desc,"cap");
26-
lsl_append_child_value(cap,"name","EasyCap");
27-
lsl_append_child_value(cap,"size","54");
28-
lsl_append_child_value(cap,"labelscheme","10-20");
24+
lsl_append_child_value(desc, "manufacturer", "SCCN");
25+
cap = lsl_append_child(desc, "cap");
26+
lsl_append_child_value(cap, "name", "EasyCap");
27+
lsl_append_child_value(cap, "size", "54");
28+
lsl_append_child_value(cap, "labelscheme", "10-20");
2929

3030
/* create outlet for the stream */
31-
outlet = lsl_create_outlet(info,0,360);
31+
outlet = lsl_create_outlet(info, 0, 360);
3232

3333
/* === the following could run on another computer === */
3434

3535
/* resolve the stream and open an inlet */
36-
lsl_resolve_byprop(&info,1,"name","MetaTester",1,LSL_FOREVER);
36+
lsl_resolve_byprop(&info, 1, "name", "MetaTester", 1, LSL_FOREVER);
3737
inlet = lsl_create_inlet(info, 360, LSL_NO_PREFERENCE, 1);
38-
inf = lsl_get_fullinfo(inlet,LSL_FOREVER,&errcode);
38+
inf = lsl_get_fullinfo(inlet, LSL_FOREVER, &errcode);
3939
printf("The stream's XML meta-data is: \n");
40-
printf("%s\n",lsl_get_xml(inf));
41-
printf("The manufacturer is: %s\n",lsl_child_value_n(lsl_get_desc(inf),"manufacturer"));
42-
printf("The cap circumference is: %s\n",lsl_child_value_n(lsl_child(lsl_get_desc(inf),"cap"),"size"));
40+
printf("%s\n", lsl_get_xml(inf));
41+
printf("The manufacturer is: %s\n", lsl_child_value_n(lsl_get_desc(inf), "manufacturer"));
42+
printf("The cap circumference is: %s\n",
43+
lsl_child_value_n(lsl_child(lsl_get_desc(inf), "cap"), "size"));
4344
printf("The channel labels are as follows:\n");
44-
chn = lsl_child(lsl_child(lsl_get_desc(inf),"channels"),"channel");
45-
for (c=0; c<lsl_get_channel_count(inf); c++) {
46-
printf(" %s\n",lsl_child_value_n(chn,"label"));
47-
chn = lsl_next_sibling(chn);
48-
}
45+
chn = lsl_child(lsl_child(lsl_get_desc(inf), "channels"), "channel");
46+
for (c = 0; c < lsl_get_channel_count(inf); c++) {
47+
printf(" %s\n", lsl_child_value_n(chn, "label"));
48+
chn = lsl_next_sibling(chn);
49+
}
4950

5051
/* destroy objects and free memory */
5152
lsl_destroy_streaminfo(inf);

examples/ReceiveData.cpp

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,33 @@
1-
#include <thread>
21
#include <iostream>
32
#include <lsl_cpp.h>
43
#include <string>
4+
#include <thread>
55

66

77
/**
88
* Example program that demonstrates how to resolve a specific stream on the lab
99
* network and how to connect to it in order to receive data.
1010
*/
1111

12-
void printChunk(const std::vector<float>& chunk, std::size_t n_channels) {
13-
for(std::size_t i=0; i < chunk.size(); ++i) {
12+
void printChunk(const std::vector<float> &chunk, std::size_t n_channels) {
13+
for (std::size_t i = 0; i < chunk.size(); ++i) {
1414
std::cout << chunk[i] << ' ';
15-
if (i % n_channels == n_channels - 1)
16-
std::cout << '\n';
15+
if (i % n_channels == n_channels - 1) std::cout << '\n';
1716
}
1817
}
1918

20-
void printChunk(const std::vector<std::vector<float>>& chunk) {
21-
for(const auto& vec: chunk)
22-
printChunk(vec, vec.size());
19+
void printChunk(const std::vector<std::vector<float>> &chunk) {
20+
for (const auto &vec : chunk) printChunk(vec, vec.size());
2321
}
2422

25-
int main(int argc, char* argv[]) {
23+
int main(int argc, char *argv[]) {
2624
std::string field, value;
2725
const int max_samples = argc > 3 ? std::stoi(argv[3]) : 10;
2826
if (argc < 3) {
2927
std::cout << "This connects to a stream which has a particular value for a "
30-
"given field and receives data.\nPlease enter a field name and the desired "
31-
"value (e.g. \"type EEG\" (without the quotes)):"
32-
<< std::endl;
28+
"given field and receives data.\nPlease enter a field name and the desired "
29+
"value (e.g. \"type EEG\" (without the quotes)):"
30+
<< std::endl;
3331
std::cin >> field >> value;
3432
} else {
3533
field = argv[1];
@@ -39,7 +37,7 @@ int main(int argc, char* argv[]) {
3937
// resolve the stream of interet
4038
std::cout << "Now resolving streams..." << std::endl;
4139
std::vector<lsl::stream_info> results = lsl::resolve_stream(field, value);
42-
if(results.empty()) throw std::runtime_error("No stream found");
40+
if (results.empty()) throw std::runtime_error("No stream found");
4341

4442
std::cout << "Here is what was resolved: " << std::endl;
4543
std::cout << results[0].as_xml() << std::endl;
@@ -54,7 +52,7 @@ int main(int argc, char* argv[]) {
5452
std::vector<float> sample;
5553
std::vector<std::vector<float>> chunk_nested_vector;
5654

57-
for(int i=0; i < max_samples; ++i) {
55+
for (int i = 0; i < max_samples; ++i) {
5856
// pull a single sample
5957
inlet.pull_sample(sample);
6058
printChunk(sample, inlet.get_channel_count());
@@ -73,7 +71,7 @@ int main(int argc, char* argv[]) {
7371
printChunk(sample, inlet.get_channel_count());
7472
}
7573

76-
if(argc == 1) {
74+
if (argc == 1) {
7775
std::cout << "Press any key to exit. " << std::endl;
7876
std::cin.get();
7977
}

0 commit comments

Comments
 (0)