• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ossia / score / 35899133125

23 Sep 2026 05:57PM UTC coverage: 41.488% (+1.2%) from 40.337%
35899133125

push

github

jcelerier
3rdparty: follow the merged libossia

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWVTQ1pm3X2Uz7goFgULtC

123236 of 297041 relevant lines covered (41.49%)

113626.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

74.68
/src/plugins/score-lib-process/Process/Process.cpp
1
// This is an open source non-commercial project. Dear PVS-Studio, please check
2
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
3
#include "Process.hpp"
4

5
#include <Process/Dataflow/PortVisibility.hpp>
6

7
#include <Process/Dataflow/Port.hpp>
8
#include <Process/ExpandMode.hpp>
9
#include <Process/PresetHelpers.hpp>
10
#include <Process/TimeValue.hpp>
11

12
#include <LocalTree/ProcessComponent.hpp>
13

14
#include <score/model/ComponentUtils.hpp>
15
#include <score/model/EntitySerialization.hpp>
16
#include <score/model/IdentifiedObject.hpp>
17
#include <score/model/Identifier.hpp>
18
#include <score/model/ModelMetadata.hpp>
19
#include <score/tools/Bind.hpp>
20
#include <score/widgets/SetIcons.hpp>
21

22
#include <ossia/detail/algorithms.hpp>
23
#include <ossia/detail/disable_fpe.hpp>
24
#include <ossia/network/base/device.hpp>
25
#include <ossia/network/base/node.hpp>
26

27
#include <QObject>
28

29
#include <wobjectimpl.h>
30

31
W_OBJECT_IMPL(Process::ProcessModel)
31,780✔
32

33
#if !defined(SCORE_ALL_UNITY)
34
template class IdentifiedObject<Process::ProcessModel>;
35
template class score::SerializableInterface<Process::ProcessModelFactory>;
36
#endif
37
namespace Process
38
{
39

40
const QIcon& getCategoryIcon(const QString& category) noexcept
70,928✔
41
{
42
  static const ossia::flat_map<QString, QIcon> categoryIcon{
73,712✔
43
      {"AI", makeIcon(QStringLiteral(":/icons/ai.png"))},
174✔
44
      {"Analysis", makeIcon(QStringLiteral(":/icons/analysis.png"))},
174✔
45
      {"Audio", makeIcon(QStringLiteral(":/icons/audio.png"))},
174✔
46
      {"Plugins", makeIcon(QStringLiteral(":/icons/filter.png"))},
174✔
47
      {"Midi", makeIcon(QStringLiteral(":/icons/midi.png"))},
174✔
48
      {"Control", makeIcon(QStringLiteral(":/icons/controls.png"))},
174✔
49
      {"Visuals", makeIcon(QStringLiteral(":/icons/gfx.png"))},
174✔
50
      {"Automations", makeIcon(QStringLiteral(":/icons/automation.png"))},
174✔
51
      {"Impro", makeIcon(QStringLiteral(":/icons/controls.png"))},
174✔
52
      {"Script", makeIcon(QStringLiteral(":/icons/script.png"))},
174✔
53
      {"Structure", makeIcon(QStringLiteral(":/icons/structure.png"))},
174✔
54
      {"Network", makeIcon(QStringLiteral(":/icons/sync.png"))},
174✔
55
      {"Monitoring", makeIcon(QStringLiteral(":/icons/ui.png"))},
174✔
56
      {"Spatial", makeIcon(QStringLiteral(":/icons/spatial.png"))},
174✔
57
      // Kept until the remaining processes are renamed to "Spatial": the icon
58
      // is looked up on the first path segment only, so both spellings need a
59
      // row or one of them renders without an icon.
60
      {"Spatialization", makeIcon(QStringLiteral(":/icons/spatial.png"))},
174✔
61
      {"Timing", makeIcon(QStringLiteral(":/icons/timing.png"))},
174✔
62
  };
63
  static const QIcon invalid;
70,928✔
64
  if(auto it = categoryIcon.find(category); it != categoryIcon.end())
70,928✔
65
  {
66
    return it->second;
70,928✔
67
  }
68
  if(auto slash_it = category.indexOf("/"); slash_it != -1)
×
69
  {
70
    if(auto it = categoryIcon.find(category.mid(0, slash_it)); it != categoryIcon.end())
×
71
    {
72
      return it->second;
×
73
    }
74
  }
×
75
  return invalid;
×
76
}
70,928✔
77
ProcessModel::ProcessModel(
3,036✔
78
    TimeVal duration, const Id<ProcessModel>& id, const QString& name, QObject* parent)
79
    : Entity{id, name, parent}
1,518✔
80
    , m_duration{std::move(duration)}
81
    , m_slotHeight{300}
82
    , m_loopDuration{m_duration}
83
    , m_size{200, 100}
84
    , m_loops{false}
85
{
3,036✔
86
  ossia::disable_fpe();
1,518✔
87
  con(metadata(), &score::ModelMetadata::NameChanged, this,
3,036✔
88
      [this] { prettyNameChanged(); });
3,132✔
89
  connect(this, &Process::ProcessModel::resetExecution, this, [this] {
2,290✔
90
    for(auto& p : this->m_inlets)
2,675✔
91
      p->executionReset();
1,903✔
92
    for(auto& p : this->m_outlets)
1,629✔
93
      p->executionReset();
857✔
94
  });
772✔
95
  // metadata().setInstanceName(*this);
96
}
×
97

98
ProcessModel::~ProcessModel()
2,396✔
99
{
2,396✔
100
  identified_object_destroying(this);
2,396✔
101
}
2,396✔
102

103
QString ProcessModel::effect() const noexcept
318✔
104
{
105
  return {};
318✔
106
}
107

108
void ProcessModel::setDurationAndScale(const TimeVal& newDuration) noexcept
×
109
{
110
  setDuration(newDuration);
×
111
}
×
112

113
void ProcessModel::setDurationAndGrow(const TimeVal& newDuration) noexcept
×
114
{
115
  setDuration(newDuration);
×
116
}
×
117

118
void ProcessModel::setDurationAndShrink(const TimeVal& newDuration) noexcept
×
119
{
120
  setDuration(newDuration);
×
121
}
×
122

123
ProcessModel::ProcessModel(DataStream::Deserializer& vis, QObject* parent)
846✔
124
    : Entity(vis, parent)
423✔
125
{
846✔
126
  ossia::disable_fpe();
423✔
127
  vis.writeTo(*this);
423✔
128
  con(metadata(), &score::ModelMetadata::NameChanged, this,
846✔
129
      [this] { prettyNameChanged(); });
423✔
130
}
×
131

132
ProcessModel::ProcessModel(JSONObject::Deserializer& vis, QObject* parent)
910✔
133
    : Entity(vis, parent)
455✔
134
{
910✔
135
  ossia::disable_fpe();
455✔
136
  vis.writeTo(*this);
455✔
137
  con(metadata(), &score::ModelMetadata::NameChanged, this,
910✔
138
      [this] { prettyNameChanged(); });
455✔
139
}
×
140

141
QString ProcessModel::prettyName() const noexcept
2,179✔
142
{
143
  return metadata().getName();
2,179✔
144
}
145

146
void ProcessModel::setParentDuration(ExpandMode mode, const TimeVal& t) noexcept
1✔
147
{
148
  switch(mode)
1✔
149
  {
150
    case ExpandMode::Scale:
151
      setDurationAndScale(t);
×
152
      break;
×
153
    case ExpandMode::GrowShrink: {
154
      if(duration() < t)
1✔
155
        setDurationAndGrow(t);
×
156
      else
157
        setDurationAndShrink(t);
1✔
158
      break;
1✔
159
    }
160
    case ExpandMode::ForceGrow: {
161
      if(duration() < t)
×
162
        setDurationAndGrow(t);
×
163
      break;
×
164
    }
165
    case ExpandMode::CannotExpand:
×
166
    default:
167
      break;
×
168
  }
169
}
1✔
170

171
TimeVal ProcessModel::contentDuration() const noexcept
×
172
{
173
  return TimeVal::zero();
×
174
}
175

176
void ProcessModel::setDuration(const TimeVal& other) noexcept
2✔
177
{
178
  m_duration = other;
2✔
179
  durationChanged(m_duration);
2✔
180
}
2✔
181

182
const TimeVal& ProcessModel::duration() const noexcept
2,349✔
183
{
184
  return m_duration;
2,349✔
185
}
186

187
ProcessStateDataInterface* ProcessModel::startStateData() const noexcept
962✔
188
{
189
  return nullptr;
962✔
190
}
191

192
ProcessStateDataInterface* ProcessModel::endStateData() const noexcept
962✔
193
{
194
  return nullptr;
962✔
195
}
196

197
Selection ProcessModel::selectableChildren() const noexcept
×
198
{
199
  return {};
×
200
}
201

202
Selection ProcessModel::selectedChildren() const noexcept
×
203
{
204
  return {};
×
205
}
206

207
void ProcessModel::setSelection(const Selection& s) const noexcept
1✔
208
{
209
  // OPTIMIZEME
210
  auto cld = this->findChildren<Selectable*>();
1✔
211
  for(Selectable* child : cld)
10✔
212
  {
213
    child->set(s.contains(child->parent()));
9✔
214
  }
215
}
1✔
216

217
Process::Inlet* ProcessModel::inlet(const Id<Process::Port>& p) const noexcept
5✔
218
{
219
  for(auto e : m_inlets)
16✔
220
    if(e->id() == p)
15✔
221
      return e;
4✔
222
  return nullptr;
1✔
223
}
5✔
224

225
Process::Outlet* ProcessModel::outlet(const Id<Process::Port>& p) const noexcept
1✔
226
{
227
  for(auto e : m_outlets)
1✔
228
    if(e->id() == p)
1✔
229
      return e;
1✔
230
  return nullptr;
×
231
}
1✔
232

233
void ProcessModel::loadPreset(const Preset& preset)
6✔
234
{
235
  const rapidjson::Document doc = readJson(preset.data);
6✔
236
  loadFixedControls(doc.GetArray(), *this);
6✔
237
}
6✔
238

239
Preset ProcessModel::savePreset() const noexcept
8✔
240
{
241
  Preset p;
8✔
242
  p.name = this->metadata().getName();
8✔
243
  p.key.key = this->concreteKey();
8✔
244

245
  JSONReader r;
8✔
246
  saveFixedControls(r, *this);
8✔
247
  p.data = r.toByteArray();
8✔
248
  return p;
8✔
249
}
8✔
250

251
std::vector<Preset> ProcessModel::builtinPresets() const noexcept
×
252
{
253
  return {};
×
254
}
255

256
void ProcessModel::ancestorStartDateChanged() { }
×
257

258
void ProcessModel::ancestorTempoChanged() { }
×
259

260
void ProcessModel::forEachControl(
×
261
    smallfun::function<void(ControlInlet&, const ossia::value&)> f) const
262
{
263
  for(const auto& inlet : m_inlets)
×
264
  {
265
    if(auto ctrl = qobject_cast<Process::ControlInlet*>(inlet))
×
266
    {
267
      f(*ctrl, ctrl->value());
×
268
    }
×
269
  }
270
}
×
271

272
void ProcessModel::setCreatingControls(bool ok) { }
×
273

274
bool ProcessModel::creatingControls() const noexcept
×
275
{
276
  return this->flags() & ProcessFlags::CreateControls;
×
277
}
278

279
void ProcessModel::setLoops(bool b)
24✔
280
{
281
  if(b != m_loops)
24✔
282
  {
283
    m_loops = b;
22✔
284
    loopsChanged(b);
22✔
285
  }
22✔
286
}
24✔
287

288
void ProcessModel::setStartOffset(TimeVal b)
10✔
289
{
290
  if(b != m_startOffset)
10✔
291
  {
292
    m_startOffset = b;
9✔
293
    startOffsetChanged(b);
9✔
294
  }
9✔
295
}
10✔
296

297
void ProcessModel::setLoopDuration(TimeVal b)
9✔
298
{
299
  if(b.msec() < 0.1)
9✔
300
    b = TimeVal::fromMsecs(0.1);
×
301

302
  if(b != m_loopDuration)
9✔
303
  {
304
    m_loopDuration = b;
9✔
305
    loopDurationChanged(b);
9✔
306
  }
9✔
307
}
9✔
308

309
QPointF ProcessModel::position() const noexcept
86,026✔
310
{
311
  return m_position;
86,026✔
312
}
313

314
QSizeF ProcessModel::size() const noexcept
83,643✔
315
{
316
  return m_size;
83,643✔
317
}
318

319
void ProcessModel::setPosition(const QPointF& v)
950✔
320
{
321
  if(v != m_position)
950✔
322
  {
323
    m_position = v;
948✔
324
    positionChanged(v);
948✔
325
  }
948✔
326
}
950✔
327

328
void ProcessModel::setSize(const QSizeF& v)
425✔
329
{
330
  if(v != m_size)
425✔
331
  {
332
    m_size = v;
425✔
333
    sizeChanged(v);
425✔
334
  }
425✔
335
}
425✔
336

337
FoldMode ProcessModel::foldMode() const noexcept
906✔
338
{
339
  return m_foldMode;
906✔
340
}
341

342
void ProcessModel::setFoldMode(FoldMode v)
6✔
343
{
344
  if(v != m_foldMode)
6✔
345
  {
346
    m_foldMode = v;
6✔
347
    foldModeChanged(v);
6✔
348
  }
6✔
349
}
6✔
350

351
bool ProcessModel::folded() const noexcept
372✔
352
{
353
  switch(m_foldMode)
372✔
354
  {
355
    case FoldMode::Folded:
356
      return true;
5✔
357
    case FoldMode::Unfolded:
358
      return false;
2✔
359
    case FoldMode::Auto:
365✔
360
    default:
361
      return std::ssize(m_inlets) > MaxUnpaginatedControls;
365✔
362
  }
363
}
372✔
364

365
double ProcessModel::getSlotHeight() const noexcept
9,663✔
366
{
367
  return m_slotHeight;
9,663✔
368
}
369

370
void ProcessModel::setSlotHeight(double v) noexcept
558✔
371
{
372
  m_slotHeight = v;
558✔
373
  slotHeightChanged(v);
558✔
374
}
558✔
375

376
void ProcessModel::setExecuting(bool e)
1,796✔
377
{
378
  m_executing = e;
1,796✔
379
}
1,796✔
380

381
std::optional<Process::MagneticInfo>
382
ProcessModel::magneticPosition(const QObject* o, const TimeVal t) const noexcept
2✔
383
{
384
  return {};
2✔
385
}
386

387
bool ProcessModel::externalSourceOutOfDate() const noexcept
×
388
{
389
  return false;
×
390
}
391

392
score::Command*
393
ProcessModel::refreshFromExternalSource(const score::DocumentContext& ctx) const
×
394
{
395
  return nullptr;
×
396
}
397

398
ProcessModel* parentProcess(QObject* obj) noexcept
11✔
399
{
400
  if(obj)
11✔
401
    obj = obj->parent();
11✔
402

403
  while(obj && !qobject_cast<ProcessModel*>(obj))
11✔
404
  {
405
    obj = obj->parent();
×
406
  }
407

408
  if(obj)
11✔
409
    return static_cast<ProcessModel*>(obj);
11✔
410
  return nullptr;
×
411
}
11✔
412

413
const ProcessModel* parentProcess(const QObject* obj) noexcept
37✔
414
{
415
  if(obj)
37✔
416
    obj = obj->parent();
37✔
417

418
  while(obj && !qobject_cast<const ProcessModel*>(obj))
37✔
419
  {
420
    obj = obj->parent();
×
421
  }
422

423
  if(obj)
37✔
424
    return static_cast<const ProcessModel*>(obj);
37✔
425
  return nullptr;
×
426
}
37✔
427

428
QString processLocalTreeAddress(const ProcessModel& proc)
×
429
{
430
  if(auto lt = findComponent<LocalTree::ProcessComponent>(proc.components()))
×
431
  {
432
    return QString::fromStdString(
×
433
        lt->node().get_device().get_name() + ":" + lt->node().osc_address());
×
434
  }
435
  return {};
×
436
}
×
437
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc