PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
PLabStreamingLayer.h
Go to the documentation of this file.
1//* -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- */
3// Name: src/utility/PLabStreamingLayer.h
4// Purpose: PEBL wrapper for Lab Streaming Layer (LSL)
5// Author: Shane T. Mueller, Ph.D.
6// Copyright: (c) 2026 Shane T. Mueller <smueller@obereed.net>
7// License: GPL 2
8//
9// This file is part of the PEBL project.
10//
11// PEBL is free software; you can redistribute it and/or modify
12// it under the terms of the GNU General Public License as published by
13// the Free Software Foundation; either version 2 of the License, or
14// (at your option) any later version.
15//
16// PEBL is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with PEBL; if not, write to the Free Software
23// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25#ifndef __PLSL_H__
26#define __PLSL_H__
27
28#include <string>
29
30#ifdef PEBL_USE_LSL
31
32// Forward declare LSL C API types to avoid including problematic lsl_cpp.h
33// We'll use the C API directly to avoid namespace pollution issues
34// Note: lsl_outlet and lsl_streaminfo are already pointer types in lsl_c.h
35extern "C" {
36 typedef struct lsl_streaminfo_struct_* lsl_streaminfo;
37 typedef struct lsl_outlet_struct_* lsl_outlet;
38}
39
45class PLSL
46{
47public:
48 // Constructor - creates LSL outlet for string markers
49 PLSL(const std::string& name,
50 const std::string& type,
51 const std::string& source_id);
52
53 // Destructor - closes outlet
54 ~PLSL();
55
56 // Send string marker
57 void SendMarker(const std::string& marker);
58
59 // Send integer marker (converted to string)
60 void SendMarker(int marker);
61
62 // Send marker with explicit timestamp
63 void SendMarkerTimed(const std::string& marker, double timestamp);
64
65 // Check if anyone is listening to this stream
66 bool HaveConsumers();
67
68 // Wait for consumers to connect (returns true if consumers found)
69 bool WaitForConsumers(double timeout);
70
71 // Check if outlet was successfully created
72 bool IsValid() const { return mOutlet != NULL; }
73
74private:
75 lsl_streaminfo mInfo;
76 lsl_outlet mOutlet;
77};
78
79#else // !PEBL_USE_LSL - Stub class declaration when LSL is disabled
80
86class PLSL
87{
88public:
89 // Constructor - no-op
90 PLSL(const std::string& name,
91 const std::string& type,
92 const std::string& source_id);
93
94 // Destructor - no-op
95 ~PLSL();
96
97 // Send string marker - no-op
98 void SendMarker(const std::string& marker);
99
100 // Send integer marker - no-op
101 void SendMarker(int marker);
102
103 // Send marker with explicit timestamp - no-op
104 void SendMarkerTimed(const std::string& marker, double timestamp);
105
106 // Always returns false when LSL disabled
107 bool HaveConsumers();
108
109 // Always returns false when LSL disabled
110 bool WaitForConsumers(double timeout);
111
112 // Always false when LSL disabled
113 bool IsValid() const { return false; }
114
115private:
116 void* mInfo; // Placeholder
117 void* mOutlet; // Placeholder
118};
119
120#endif // PEBL_USE_LSL
121#endif // __PLSL_H__
#define NULL
Definition BinReloc.cpp:317
bool IsValid() const
bool HaveConsumers()
bool WaitForConsumers(double timeout)
void SendMarker(const std::string &marker)
void SendMarkerTimed(const std::string &marker, double timestamp)