summaryrefslogtreecommitdiffstats
path: root/scilab/modules/scicos/src/cpp/Controller.cpp
blob: 951f44aebe117df546c62c1f6bd98187b2b3443e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
/*
 *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 *  Copyright (C) 2014-2016 - Scilab Enterprises - Clement DAVID
 *
 * Copyright (C) 2012 - 2016 - Scilab Enterprises
 *
 * This file is hereby licensed under the terms of the GNU GPL v2.0,
 * pursuant to article 5.3.4 of the CeCILL v.2.1.
 * This file was originally licensed under the terms of the CeCILL v2.1,
 * and continues to be available under such terms.
 * For more information, see the COPYING file which you should have received
 * along with this program.
 *
 */

#include <atomic>
#include <string>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <iterator>

#include "utilities.hxx"

#include "Controller.hxx"
#include "model/BaseObject.hxx"

#include "LoggerView.hxx"

extern "C" {
#include "scicos.h"
}

namespace org_scilab_modules_scicos
{

/*
 * Implement SharedData methods
 */
Controller::SharedData::SharedData() :
    onModelStructuralModification(), model(),
    onViewsStructuralModification(), allNamedViews(), allViews()
{
    unlock(&onModelStructuralModification);
    unlock(&onViewsStructuralModification);
}

Controller::SharedData::~SharedData()
{
    lock(&onViewsStructuralModification);
    for (view_set_t::iterator iter = allViews.begin(); iter != allViews.end(); ++iter)
    {
        delete *iter;
    }
    unlock(&onViewsStructuralModification);
}

Controller::SharedData Controller::m_instance;

View* Controller::register_view(const std::string& name, View* v)
{
    lock(&m_instance.onViewsStructuralModification);

    m_instance.allNamedViews.push_back(name);
    m_instance.allViews.push_back(v);

    unlock(&m_instance.onViewsStructuralModification);
    return v;
}

void Controller::unregister_view(View* v)
{
    lock(&m_instance.onViewsStructuralModification);

    view_set_t::iterator it = std::find(m_instance.allViews.begin(), m_instance.allViews.end(), v);
    if (it != m_instance.allViews.end())
    {
        size_t d = std::distance(m_instance.allViews.begin(), it);
        m_instance.allNamedViews.erase(m_instance.allNamedViews.begin() + d);
        m_instance.allViews.erase(m_instance.allViews.begin() + d);
    }

    unlock(&m_instance.onViewsStructuralModification);
}

View* Controller::unregister_view(const std::string& name)
{
    View* view = nullptr;

    lock(&m_instance.onViewsStructuralModification);

    view_name_set_t::iterator it = std::find(m_instance.allNamedViews.begin(), m_instance.allNamedViews.end(), name);
    if (it != m_instance.allNamedViews.end())
    {
        size_t d = std::distance(m_instance.allNamedViews.begin(), it);
        view = *(m_instance.allViews.begin() + d);
        m_instance.allNamedViews.erase(m_instance.allNamedViews.begin() + d);
        m_instance.allViews.erase(m_instance.allViews.begin() + d);
    }
    unlock(&m_instance.onViewsStructuralModification);

    return view;
}

View* Controller::look_for_view(const std::string& name)
{
    View* view = nullptr;

    lock(&m_instance.onViewsStructuralModification);
    view_name_set_t::iterator it = std::find(m_instance.allNamedViews.begin(), m_instance.allNamedViews.end(), name);
    if (it != m_instance.allNamedViews.end())
    {
        size_t d = std::distance(m_instance.allNamedViews.begin(), it);
        view = *(m_instance.allViews.begin() + d);
    }
    unlock(&m_instance.onViewsStructuralModification);

    return view;
}

void Controller::end_simulation()
{
    end_scicos_sim();
}

Controller::Controller()
{
}

Controller::~Controller()
{
}

ScicosID Controller::createObject(kind_t k)
{
    lock(&m_instance.onModelStructuralModification);
    ScicosID uid = m_instance.model.createObject(k);
    unlock(&m_instance.onModelStructuralModification);

    lock(&m_instance.onViewsStructuralModification);
    for (view_set_t::iterator iter = m_instance.allViews.begin(); iter != m_instance.allViews.end(); ++iter)
    {
        (*iter)->objectCreated(uid, k);
    }
    unlock(&m_instance.onViewsStructuralModification);

    return uid;
}

unsigned Controller::referenceObject(const ScicosID uid) const
{
    lock(&m_instance.onModelStructuralModification);

    unsigned refCount = m_instance.model.referenceObject(uid);

    auto o = m_instance.model.getObject(uid);
    unlock(&m_instance.onModelStructuralModification);
    if (o == nullptr)
    {
        // defensive programming
        return 0u;
    }

    lock(&m_instance.onViewsStructuralModification);
    for (view_set_t::iterator iter = m_instance.allViews.begin(); iter != m_instance.allViews.end(); ++iter)
    {
        (*iter)->objectReferenced(uid, o->kind(), refCount);
    }
    unlock(&m_instance.onViewsStructuralModification);

    return refCount;
}

void Controller::deleteObject(ScicosID uid)
{
    // if this object is the empty uid, ignore it : is is not stored in the model
    if (uid == ScicosID())
    {
        return;
    }

    lock(&m_instance.onModelStructuralModification);

    auto initial = m_instance.model.getObject(uid);
    if (initial == nullptr)
    {
        // defensive programming
        unlock(&m_instance.onModelStructuralModification);
        return;
    }
    const kind_t k = initial->kind();

    // if this object has been referenced somewhere else do not delete it but decrement the reference counter
    unsigned& refCount = m_instance.model.referenceCount(uid);
    unlock(&m_instance.onModelStructuralModification);
    if (refCount > 0)
    {
        --refCount;

        lock(&m_instance.onViewsStructuralModification);
        for (view_set_t::iterator iter = m_instance.allViews.begin(); iter != m_instance.allViews.end(); ++iter)
        {
            (*iter)->objectUnreferenced(uid, k, refCount);
        }
        unlock(&m_instance.onViewsStructuralModification);
        return;
    }

    // We need to delete this object and cleanup all the referenced model object

    // disconnect / remove references of weak connected objects and decrement the reference count of all strongly connected objects.
    if (k == ANNOTATION)
    {
        unlinkVector(initial, PARENT_DIAGRAM, CHILDREN);
        unlinkVector(initial, PARENT_BLOCK, CHILDREN);
        // RELATED_TO is not referenced back
    }
    else if (k == BLOCK)
    {
        unlinkVector(initial, PARENT_DIAGRAM, CHILDREN);
        unlinkVector(initial, PARENT_BLOCK, CHILDREN);

        deleteVector(initial, INPUTS);
        deleteVector(initial, OUTPUTS);
        deleteVector(initial, EVENT_INPUTS);
        deleteVector(initial, EVENT_OUTPUTS);

        unlink(initial, CHILDREN, PARENT_BLOCK);
        deleteVector(initial, CHILDREN);
        // FIXME what about REFERENCED_PORT ?
    }
    else if (k == DIAGRAM)
    {
        unlink(initial, CHILDREN, PARENT_DIAGRAM);
        deleteVector(initial, CHILDREN);
    }
    else if (k == LINK)
    {
        unlinkVector(initial, PARENT_DIAGRAM, CHILDREN);
        unlinkVector(initial, PARENT_BLOCK, CHILDREN);

        unlinkVector(initial, SOURCE_PORT, CONNECTED_SIGNALS);
        unlinkVector(initial, DESTINATION_PORT, CONNECTED_SIGNALS);
    }
    else if (k == PORT)
    {
        unlinkVector(initial, SOURCE_BLOCK, INPUTS);
        unlinkVector(initial, SOURCE_BLOCK, OUTPUTS);
        unlinkVector(initial, SOURCE_BLOCK, EVENT_INPUTS);
        unlinkVector(initial, SOURCE_BLOCK, EVENT_OUTPUTS);

        unlink(initial, CONNECTED_SIGNALS, SOURCE_PORT);
        unlink(initial, CONNECTED_SIGNALS, DESTINATION_PORT);
    }

    // delete the object
    lock(&m_instance.onModelStructuralModification);
    m_instance.model.deleteObject(uid);
    unlock(&m_instance.onModelStructuralModification);

    lock(&m_instance.onViewsStructuralModification);
    for (view_set_t::iterator iter = m_instance.allViews.begin(); iter != m_instance.allViews.end(); ++iter)
    {
        (*iter)->objectDeleted(uid, k);
    }
    unlock(&m_instance.onViewsStructuralModification);
}

void Controller::unlinkVector(model::BaseObject* initial, object_properties_t uid_prop, object_properties_t ref_prop)
{
    ScicosID v;
    getObjectProperty(initial->id(), initial->kind(), uid_prop, v);
    if (v != ScicosID())
    {
        auto o = getObject(v);
        if (o == nullptr)
        {
            return;
        }

        std::vector<ScicosID> children;
        getObjectProperty(o->id(), o->kind(), ref_prop, children);

        std::vector<ScicosID>::iterator it = std::find(children.begin(), children.end(), initial->id());
        if (it != children.end())
        {
            children.erase(it);
        }

        setObjectProperty(o->id(), o->kind(), ref_prop, children);
    }
}

void Controller::unlink(model::BaseObject* initial, object_properties_t uid_prop, object_properties_t ref_prop)
{
    std::vector<ScicosID> v;
    getObjectProperty(initial->id(), initial->kind(), uid_prop, v);
    for (const ScicosID id : v)
    {
        if (id != ScicosID())
        {
            auto o = getObject(id);
            if (o == nullptr)
            {
                continue;
            }

            // Find which end of the link is connected to the port
            ScicosID oppositeRef;
            getObjectProperty(o->id(), o->kind(), ref_prop, oppositeRef);
            if (oppositeRef == initial->id())
            {
                setObjectProperty(o->id(), o->kind(), ref_prop, ScicosID());
            }
        }
    }
}

void Controller::deleteVector(model::BaseObject* initial, object_properties_t uid_prop)
{
    std::vector<ScicosID> children;
    getObjectProperty(initial->id(), initial->kind(), uid_prop, children);

    for (ScicosID id : children)
    {
        deleteObject(id);
    }
}

template<typename T>
void Controller::cloneProperties(model::BaseObject* initial, model::BaseObject* clone)
{
    for (int i = 0; i < MAX_OBJECT_PROPERTIES; ++i)
    {
        enum object_properties_t p = static_cast<enum object_properties_t>(i);

        T value;
        bool status = getObjectProperty(initial, p, value);
        if (status)
        {
            setObjectProperty(clone, p, value);
        }
    }
}

model::BaseObject* Controller::cloneObject(std::map<model::BaseObject*, model::BaseObject*>& mapped, model::BaseObject* initial, bool cloneChildren, bool clonePorts)
{
    const kind_t k = initial->kind();
    ScicosID o = createObject(k);
    model::BaseObject* cloned = getObject(o);
    mapped.insert(std::make_pair(initial, cloned));

    lock(&m_instance.onViewsStructuralModification);
    for (view_set_t::iterator iter = m_instance.allViews.begin(); iter != m_instance.allViews.end(); ++iter)
    {
        (*iter)->objectCloned(initial->id(), o, k);
    }
    unlock(&m_instance.onViewsStructuralModification);

    // Get then set all properties per type that do not manage ScicosID
    cloneProperties<double>(initial, cloned);
    cloneProperties<int>(initial, cloned);
    cloneProperties<bool>(initial, cloned);
    cloneProperties<std::string>(initial, cloned);
    cloneProperties<std::vector<double> >(initial, cloned);
    cloneProperties<std::vector<int> >(initial, cloned);
    cloneProperties<std::vector<std::string> >(initial, cloned);

    // deep copy children, manage ScicosID and std::vector<ScicosID>
    if (k == ANNOTATION)
    {
        deepClone(mapped, initial, cloned, PARENT_DIAGRAM, false);
        deepClone(mapped, initial, cloned, PARENT_BLOCK, false);
        deepClone(mapped, initial, cloned, RELATED_TO, true);
    }
    else if (k == BLOCK)
    {
        deepClone(mapped, initial, cloned, PARENT_DIAGRAM, false);
        if (clonePorts)
        {
            // copy the block and all its ports
            deepCloneVector(mapped, initial, cloned, INPUTS, true);
            deepCloneVector(mapped, initial, cloned, OUTPUTS, true);
            deepCloneVector(mapped, initial, cloned, EVENT_INPUTS, true);
            deepCloneVector(mapped, initial, cloned, EVENT_OUTPUTS, true);
        }

        deepClone(mapped, initial, cloned, PARENT_BLOCK, false);
        if (cloneChildren)
        {
            deepCloneVector(mapped, initial, cloned, CHILDREN, true);
        }
        // FIXME what about REFERENCED_PORT ?
    }
    else if (k == DIAGRAM)
    {
        if (cloneChildren)
        {
            deepCloneVector(mapped, initial, cloned, CHILDREN, true);
        }
    }
    else if (k == LINK)
    {
        deepClone(mapped, initial, cloned, PARENT_DIAGRAM, false);
        deepClone(mapped, initial, cloned, PARENT_BLOCK, false);
        deepClone(mapped, initial, cloned, SOURCE_PORT, false);
        deepClone(mapped, initial, cloned, DESTINATION_PORT, false);
    }
    else if (k == PORT)
    {
        deepClone(mapped, initial, cloned, SOURCE_BLOCK, false);
        deepCloneVector(mapped, initial, cloned, CONNECTED_SIGNALS, false);
    }
    return cloned;
}

void Controller::deepClone(std::map<model::BaseObject*, model::BaseObject*>& mapped, model::BaseObject* initial, model::BaseObject* clone, object_properties_t p, bool cloneIfNotFound)
{
    ScicosID v;
    getObjectProperty(initial, p, v);

    model::BaseObject* opposite = getObject(v);
    model::BaseObject* cloned;

    std::map<model::BaseObject*, model::BaseObject*>::iterator it = mapped.find(opposite);
    if (it != mapped.end())
    {
        cloned = it->second;
    }
    else
    {
        if (cloneIfNotFound)
        {
            if (v != ScicosID())
            {
                cloned = cloneObject(mapped, opposite, true, true);
            }
            else
            {
                cloned = nullptr;
            }
        }
        else
        {
            cloned = nullptr;
        }
    }

    if (cloned == nullptr)
    {
        setObjectProperty(clone, p, ScicosID());
    }
    else
    {
        setObjectProperty(clone, p, cloned->id());
    }
}

void Controller::deepCloneVector(std::map<model::BaseObject*, model::BaseObject*>& mapped, model::BaseObject* initial, model::BaseObject* clone, object_properties_t p, bool cloneIfNotFound)
{
    std::vector<ScicosID> v;
    getObjectProperty(initial, p, v);

    std::vector<model::BaseObject*> cloned;
    cloned.reserve(v.size());

    for (const ScicosID & id : v)
    {
        if (id == ScicosID())
        {
            // Deleted Block, the cloning is done at Adapter level
            cloned.push_back(nullptr);
            continue;
        }

        model::BaseObject* opposite = getObject(id);
        std::map<model::BaseObject*, model::BaseObject*>::iterator it = mapped.find(opposite);
        if (it != mapped.end())
        {
            cloned.push_back(it->second);
        }
        else
        {
            if (cloneIfNotFound)
            {
                if (id != ScicosID())
                {
                    model::BaseObject* clone = cloneObject(mapped, opposite, true, true);
                    cloned.push_back(clone);
                }
                else
                {
                    cloned.push_back(nullptr);
                }
            }
            else
            {
                cloned.push_back(getObject(id));
            }
        }
    }

    // update the ScicosID related properties after cloning all the objects
    if (p == CHILDREN)
    {
        for (auto const& it : mapped)
        {
            model::BaseObject* initial = it.first;
            model::BaseObject* cloned = it.second;

            switch (initial->kind())
            {
                case PORT:
                    deepCloneVector(mapped, initial, cloned, CONNECTED_SIGNALS, false);
                    break;
                case LINK:
                    deepClone(mapped, initial, cloned, SOURCE_PORT, false);
                    deepClone(mapped, initial, cloned, DESTINATION_PORT, false);
                    break;
                default:
                    break;
            }
        }
    }

    // set the main object vector property
    std::vector<ScicosID> clonedUIDs(cloned.size());
    std::transform(cloned.begin(), cloned.end(), clonedUIDs.begin(), [](model::BaseObject * o)
    {
        if (o == nullptr)
        {
            return ScicosID();
        }
        else
        {
            return o->id();
        }
    });

    setObjectProperty(clone, p, clonedUIDs);
}

ScicosID Controller::cloneObject(ScicosID uid, bool cloneChildren, bool clonePorts)
{
    std::map<model::BaseObject*, model::BaseObject*> mapped;
    model::BaseObject* clone = cloneObject(mapped, getObject(uid), cloneChildren, clonePorts);

    return clone->id();
}

kind_t Controller::getKind(ScicosID uid) const
{
    lock(&m_instance.onModelStructuralModification);

    kind_t kind = m_instance.model.getKind(uid);

    unlock(&m_instance.onModelStructuralModification);
    return kind;
}

std::vector<ScicosID> Controller::getAll(kind_t k) const
{
    lock(&m_instance.onModelStructuralModification);

    auto vec = m_instance.model.getAll(k);

    unlock(&m_instance.onModelStructuralModification);
    return vec;
}

void Controller::sortAndFillKind(std::vector<ScicosID>& uids, std::vector<int>& kinds)
{
    lock(&m_instance.onModelStructuralModification);

    // create a container of pair
    struct local_pair
    {
        ScicosID first;
        int second;
    };
    std::vector<local_pair> container(uids.size());

    // fill it
    for (size_t i = 0; i < uids.size(); ++i)
    {
        container[i] = { uids[i], m_instance.model.getKind(uids[i]) };
    }

    // sort according to the kinds
    std::stable_sort(container.begin(), container.end(), [] (const local_pair & a, const local_pair & b)
    {
        return a.second < b.second;
    });

    // move things back
    uids.clear();
    kinds.reserve(uids.capacity());
    for (const auto & v : container)
    {
        uids.push_back(v.first);
        kinds.push_back(v.second);
    }

    unlock(&m_instance.onModelStructuralModification);
}

template<typename T>
bool Controller::getObjectProperty(ScicosID uid, kind_t k, object_properties_t p, T& v) const
{
    lock(&m_instance.onModelStructuralModification);
    bool ret = m_instance.model.getObjectProperty(uid, k, p, v);
    unlock(&m_instance.onModelStructuralModification);
    return ret;
}

bool Controller::getObjectProperty(ScicosID uid, kind_t k, object_properties_t p, double& v) const
{
    return getObjectProperty<>(uid, k, p, v);
}
bool Controller::getObjectProperty(ScicosID uid, kind_t k, object_properties_t p, int& v) const
{
    return getObjectProperty<>(uid, k, p, v);
}
bool Controller::getObjectProperty(ScicosID uid, kind_t k, object_properties_t p, bool& v) const
{
    return getObjectProperty<>(uid, k, p, v);
}
bool Controller::getObjectProperty(ScicosID uid, kind_t k, object_properties_t p, std::string& v) const
{
    return getObjectProperty<>(uid, k, p, v);
}
bool Controller::getObjectProperty(ScicosID uid, kind_t k, object_properties_t p, ScicosID& v) const
{
    return getObjectProperty<>(uid, k, p, v);
}
bool Controller::getObjectProperty(ScicosID uid, kind_t k, object_properties_t p, std::vector<double>& v) const
{
    return getObjectProperty<>(uid, k, p, v);
}
bool Controller::getObjectProperty(ScicosID uid, kind_t k, object_properties_t p, std::vector<int>& v) const
{
    return getObjectProperty<>(uid, k, p, v);
}
bool Controller::getObjectProperty(ScicosID uid, kind_t k, object_properties_t p, std::vector<bool>& v) const
{
    return getObjectProperty<>(uid, k, p, v);
}
bool Controller::getObjectProperty(ScicosID uid, kind_t k, object_properties_t p, std::vector< std::string >& v) const
{
    return getObjectProperty<>(uid, k, p, v);
}
bool Controller::getObjectProperty(ScicosID uid, kind_t k, object_properties_t p, std::vector<ScicosID>& v) const
{
    return getObjectProperty<>(uid, k, p, v);
}

template<typename T>
update_status_t Controller::setObjectProperty(ScicosID uid, kind_t k, object_properties_t p, T v)
{
    lock(&m_instance.onModelStructuralModification);
    update_status_t status = m_instance.model.setObjectProperty(uid, k, p, v);
    unlock(&m_instance.onModelStructuralModification);

    lock(&m_instance.onViewsStructuralModification);
    for (view_set_t::iterator iter = m_instance.allViews.begin(); iter != m_instance.allViews.end(); ++iter)
    {
        (*iter)->propertyUpdated(uid, k, p, status);
    }
    unlock(&m_instance.onViewsStructuralModification);
    return status;
}

update_status_t Controller::setObjectProperty(ScicosID uid, kind_t k, object_properties_t p, double v)
{
    return setObjectProperty<>(uid, k, p, v);
}
update_status_t Controller::setObjectProperty(ScicosID uid, kind_t k, object_properties_t p, int v)
{
    return setObjectProperty<>(uid, k, p, v);
}
update_status_t Controller::setObjectProperty(ScicosID uid, kind_t k, object_properties_t p, bool v)
{
    return setObjectProperty<>(uid, k, p, v);
}
update_status_t Controller::setObjectProperty(ScicosID uid, kind_t k, object_properties_t p, ScicosID v)
{
    return setObjectProperty<>(uid, k, p, v);
}
update_status_t Controller::setObjectProperty(ScicosID uid, kind_t k, object_properties_t p, const std::string& v)
{
    return setObjectProperty<>(uid, k, p, v);
}
update_status_t Controller::setObjectProperty(ScicosID uid, kind_t k, object_properties_t p, const std::vector<double>& v)
{
    return setObjectProperty<>(uid, k, p, v);
}
update_status_t Controller::setObjectProperty(ScicosID uid, kind_t k, object_properties_t p, const std::vector<int>& v)
{
    return setObjectProperty<>(uid, k, p, v);
}
update_status_t Controller::setObjectProperty(ScicosID uid, kind_t k, object_properties_t p, const std::vector<bool>& v)
{
    return setObjectProperty<>(uid, k, p, v);
}
update_status_t Controller::setObjectProperty(ScicosID uid, kind_t k, object_properties_t p, const std::vector< std::string >& v)
{
    return setObjectProperty<>(uid, k, p, v);
}
update_status_t Controller::setObjectProperty(ScicosID uid, kind_t k, object_properties_t p, const std::vector<ScicosID>& v)
{
    return setObjectProperty<>(uid, k, p, v);
}

model::BaseObject* Controller::getObject(ScicosID uid) const
{
    lock(&m_instance.onModelStructuralModification);
    model::BaseObject* o = m_instance.model.getObject(uid);
    unlock(&m_instance.onModelStructuralModification);
    return o;
}

} /* namespace org_scilab_modules_scicos */