00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <interfaces/FacerInterface.h>
00025
00026 #include <core/exceptions/software.h>
00027
00028 #include <cstring>
00029 #include <cstdlib>
00030
00031 namespace fawkes {
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 FacerInterface::FacerInterface() : Interface()
00049 {
00050 data_size = sizeof(FacerInterface_data_t);
00051 data_ptr = malloc(data_size);
00052 data = (FacerInterface_data_t *)data_ptr;
00053 data_ts = (interface_data_ts_t *)data_ptr;
00054 memset(data_ptr, 0, data_size);
00055 add_fieldinfo(IFT_ENUM, "opmode", 1, &data->opmode, "if_facer_opmode_t");
00056 add_fieldinfo(IFT_UINT32, "num_identities", 1, &data->num_identities);
00057 add_fieldinfo(IFT_UINT32, "recognized_identity", 1, &data->recognized_identity);
00058 add_fieldinfo(IFT_STRING, "recognized_name", 64, data->recognized_name);
00059 add_fieldinfo(IFT_UINT32, "num_detections", 1, &data->num_detections);
00060 add_fieldinfo(IFT_UINT32, "num_recognitions", 1, &data->num_recognitions);
00061 add_fieldinfo(IFT_UINT32, "most_likely_identity", 1, &data->most_likely_identity);
00062 add_fieldinfo(IFT_FLOAT, "history_ratio", 1, &data->history_ratio);
00063 add_fieldinfo(IFT_FLOAT, "sec_since_detection", 1, &data->sec_since_detection);
00064 add_fieldinfo(IFT_INT32, "visibility_history", 1, &data->visibility_history);
00065 add_fieldinfo(IFT_BOOL, "learning_in_progress", 1, &data->learning_in_progress);
00066 add_fieldinfo(IFT_FLOAT, "recording_progress", 1, &data->recording_progress);
00067 add_fieldinfo(IFT_FLOAT, "bearing", 1, &data->bearing);
00068 add_fieldinfo(IFT_FLOAT, "slope", 1, &data->slope);
00069 add_fieldinfo(IFT_UINT32, "requested_index", 1, &data->requested_index);
00070 add_fieldinfo(IFT_STRING, "requested_name", 64, data->requested_name);
00071 add_messageinfo("LearnFaceMessage");
00072 add_messageinfo("SetOpmodeMessage");
00073 add_messageinfo("EnableIdentityMessage");
00074 add_messageinfo("SetNameMessage");
00075 add_messageinfo("GetNameMessage");
00076 unsigned char tmp_hash[] = {0xe1, 0x12, 0xd2, 0x51, 0x1d, 0x24, 0x1b, 0x27, 0x86, 0xce, 0x29, 0x32, 0xd6, 0x5a, 0x5e, 0xb3};
00077 set_hash(tmp_hash);
00078 }
00079
00080
00081 FacerInterface::~FacerInterface()
00082 {
00083 free(data_ptr);
00084 }
00085
00086
00087
00088
00089 const char *
00090 FacerInterface::tostring_if_facer_opmode_t(if_facer_opmode_t value) const
00091 {
00092 switch (value) {
00093 case OPMODE_DISABLED: return "OPMODE_DISABLED";
00094 case OPMODE_DETECTION: return "OPMODE_DETECTION";
00095 case OPMODE_RECOGNITION: return "OPMODE_RECOGNITION";
00096 case OPMODE_LEARNING: return "OPMODE_LEARNING";
00097 default: return "UNKNOWN";
00098 }
00099 }
00100
00101
00102
00103
00104
00105
00106
00107 FacerInterface::if_facer_opmode_t
00108 FacerInterface::opmode() const
00109 {
00110 return data->opmode;
00111 }
00112
00113
00114
00115
00116
00117 size_t
00118 FacerInterface::maxlenof_opmode() const
00119 {
00120 return 1;
00121 }
00122
00123
00124
00125
00126
00127
00128
00129 void
00130 FacerInterface::set_opmode(const if_facer_opmode_t new_opmode)
00131 {
00132 data->opmode = new_opmode;
00133 data_changed = true;
00134 }
00135
00136
00137
00138
00139
00140
00141
00142 uint32_t
00143 FacerInterface::num_identities() const
00144 {
00145 return data->num_identities;
00146 }
00147
00148
00149
00150
00151
00152 size_t
00153 FacerInterface::maxlenof_num_identities() const
00154 {
00155 return 1;
00156 }
00157
00158
00159
00160
00161
00162
00163
00164 void
00165 FacerInterface::set_num_identities(const uint32_t new_num_identities)
00166 {
00167 data->num_identities = new_num_identities;
00168 data_changed = true;
00169 }
00170
00171
00172
00173
00174
00175
00176
00177 uint32_t
00178 FacerInterface::recognized_identity() const
00179 {
00180 return data->recognized_identity;
00181 }
00182
00183
00184
00185
00186
00187 size_t
00188 FacerInterface::maxlenof_recognized_identity() const
00189 {
00190 return 1;
00191 }
00192
00193
00194
00195
00196
00197
00198
00199 void
00200 FacerInterface::set_recognized_identity(const uint32_t new_recognized_identity)
00201 {
00202 data->recognized_identity = new_recognized_identity;
00203 data_changed = true;
00204 }
00205
00206
00207
00208
00209
00210
00211
00212 char *
00213 FacerInterface::recognized_name() const
00214 {
00215 return data->recognized_name;
00216 }
00217
00218
00219
00220
00221
00222 size_t
00223 FacerInterface::maxlenof_recognized_name() const
00224 {
00225 return 64;
00226 }
00227
00228
00229
00230
00231
00232
00233
00234 void
00235 FacerInterface::set_recognized_name(const char * new_recognized_name)
00236 {
00237 strncpy(data->recognized_name, new_recognized_name, sizeof(data->recognized_name));
00238 data_changed = true;
00239 }
00240
00241
00242
00243
00244
00245
00246
00247 uint32_t
00248 FacerInterface::num_detections() const
00249 {
00250 return data->num_detections;
00251 }
00252
00253
00254
00255
00256
00257 size_t
00258 FacerInterface::maxlenof_num_detections() const
00259 {
00260 return 1;
00261 }
00262
00263
00264
00265
00266
00267
00268
00269 void
00270 FacerInterface::set_num_detections(const uint32_t new_num_detections)
00271 {
00272 data->num_detections = new_num_detections;
00273 data_changed = true;
00274 }
00275
00276
00277
00278
00279
00280
00281
00282 uint32_t
00283 FacerInterface::num_recognitions() const
00284 {
00285 return data->num_recognitions;
00286 }
00287
00288
00289
00290
00291
00292 size_t
00293 FacerInterface::maxlenof_num_recognitions() const
00294 {
00295 return 1;
00296 }
00297
00298
00299
00300
00301
00302
00303
00304 void
00305 FacerInterface::set_num_recognitions(const uint32_t new_num_recognitions)
00306 {
00307 data->num_recognitions = new_num_recognitions;
00308 data_changed = true;
00309 }
00310
00311
00312
00313
00314
00315
00316
00317 uint32_t
00318 FacerInterface::most_likely_identity() const
00319 {
00320 return data->most_likely_identity;
00321 }
00322
00323
00324
00325
00326
00327 size_t
00328 FacerInterface::maxlenof_most_likely_identity() const
00329 {
00330 return 1;
00331 }
00332
00333
00334
00335
00336
00337
00338
00339 void
00340 FacerInterface::set_most_likely_identity(const uint32_t new_most_likely_identity)
00341 {
00342 data->most_likely_identity = new_most_likely_identity;
00343 data_changed = true;
00344 }
00345
00346
00347
00348
00349
00350
00351
00352
00353 float
00354 FacerInterface::history_ratio() const
00355 {
00356 return data->history_ratio;
00357 }
00358
00359
00360
00361
00362
00363 size_t
00364 FacerInterface::maxlenof_history_ratio() const
00365 {
00366 return 1;
00367 }
00368
00369
00370
00371
00372
00373
00374
00375
00376 void
00377 FacerInterface::set_history_ratio(const float new_history_ratio)
00378 {
00379 data->history_ratio = new_history_ratio;
00380 data_changed = true;
00381 }
00382
00383
00384
00385
00386
00387
00388
00389 float
00390 FacerInterface::sec_since_detection() const
00391 {
00392 return data->sec_since_detection;
00393 }
00394
00395
00396
00397
00398
00399 size_t
00400 FacerInterface::maxlenof_sec_since_detection() const
00401 {
00402 return 1;
00403 }
00404
00405
00406
00407
00408
00409
00410
00411 void
00412 FacerInterface::set_sec_since_detection(const float new_sec_since_detection)
00413 {
00414 data->sec_since_detection = new_sec_since_detection;
00415 data_changed = true;
00416 }
00417
00418
00419
00420
00421
00422
00423
00424
00425 int32_t
00426 FacerInterface::visibility_history() const
00427 {
00428 return data->visibility_history;
00429 }
00430
00431
00432
00433
00434
00435 size_t
00436 FacerInterface::maxlenof_visibility_history() const
00437 {
00438 return 1;
00439 }
00440
00441
00442
00443
00444
00445
00446
00447
00448 void
00449 FacerInterface::set_visibility_history(const int32_t new_visibility_history)
00450 {
00451 data->visibility_history = new_visibility_history;
00452 data_changed = true;
00453 }
00454
00455
00456
00457
00458
00459
00460
00461
00462 bool
00463 FacerInterface::is_learning_in_progress() const
00464 {
00465 return data->learning_in_progress;
00466 }
00467
00468
00469
00470
00471
00472 size_t
00473 FacerInterface::maxlenof_learning_in_progress() const
00474 {
00475 return 1;
00476 }
00477
00478
00479
00480
00481
00482
00483
00484
00485 void
00486 FacerInterface::set_learning_in_progress(const bool new_learning_in_progress)
00487 {
00488 data->learning_in_progress = new_learning_in_progress;
00489 data_changed = true;
00490 }
00491
00492
00493
00494
00495
00496
00497
00498 float
00499 FacerInterface::recording_progress() const
00500 {
00501 return data->recording_progress;
00502 }
00503
00504
00505
00506
00507
00508 size_t
00509 FacerInterface::maxlenof_recording_progress() const
00510 {
00511 return 1;
00512 }
00513
00514
00515
00516
00517
00518
00519
00520 void
00521 FacerInterface::set_recording_progress(const float new_recording_progress)
00522 {
00523 data->recording_progress = new_recording_progress;
00524 data_changed = true;
00525 }
00526
00527
00528
00529
00530
00531
00532
00533 float
00534 FacerInterface::bearing() const
00535 {
00536 return data->bearing;
00537 }
00538
00539
00540
00541
00542
00543 size_t
00544 FacerInterface::maxlenof_bearing() const
00545 {
00546 return 1;
00547 }
00548
00549
00550
00551
00552
00553
00554
00555 void
00556 FacerInterface::set_bearing(const float new_bearing)
00557 {
00558 data->bearing = new_bearing;
00559 data_changed = true;
00560 }
00561
00562
00563
00564
00565
00566
00567
00568 float
00569 FacerInterface::slope() const
00570 {
00571 return data->slope;
00572 }
00573
00574
00575
00576
00577
00578 size_t
00579 FacerInterface::maxlenof_slope() const
00580 {
00581 return 1;
00582 }
00583
00584
00585
00586
00587
00588
00589
00590 void
00591 FacerInterface::set_slope(const float new_slope)
00592 {
00593 data->slope = new_slope;
00594 data_changed = true;
00595 }
00596
00597
00598
00599
00600
00601
00602
00603 uint32_t
00604 FacerInterface::requested_index() const
00605 {
00606 return data->requested_index;
00607 }
00608
00609
00610
00611
00612
00613 size_t
00614 FacerInterface::maxlenof_requested_index() const
00615 {
00616 return 1;
00617 }
00618
00619
00620
00621
00622
00623
00624
00625 void
00626 FacerInterface::set_requested_index(const uint32_t new_requested_index)
00627 {
00628 data->requested_index = new_requested_index;
00629 data_changed = true;
00630 }
00631
00632
00633
00634
00635
00636
00637
00638 char *
00639 FacerInterface::requested_name() const
00640 {
00641 return data->requested_name;
00642 }
00643
00644
00645
00646
00647
00648 size_t
00649 FacerInterface::maxlenof_requested_name() const
00650 {
00651 return 64;
00652 }
00653
00654
00655
00656
00657
00658
00659
00660 void
00661 FacerInterface::set_requested_name(const char * new_requested_name)
00662 {
00663 strncpy(data->requested_name, new_requested_name, sizeof(data->requested_name));
00664 data_changed = true;
00665 }
00666
00667
00668 Message *
00669 FacerInterface::create_message(const char *type) const
00670 {
00671 if ( strncmp("LearnFaceMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00672 return new LearnFaceMessage();
00673 } else if ( strncmp("SetOpmodeMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00674 return new SetOpmodeMessage();
00675 } else if ( strncmp("EnableIdentityMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00676 return new EnableIdentityMessage();
00677 } else if ( strncmp("SetNameMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00678 return new SetNameMessage();
00679 } else if ( strncmp("GetNameMessage", type, __INTERFACE_MESSAGE_TYPE_SIZE) == 0 ) {
00680 return new GetNameMessage();
00681 } else {
00682 throw UnknownTypeException("The given type '%s' does not match any known "
00683 "message type for this interface type.", type);
00684 }
00685 }
00686
00687
00688
00689
00690
00691 void
00692 FacerInterface::copy_values(const Interface *other)
00693 {
00694 const FacerInterface *oi = dynamic_cast<const FacerInterface *>(other);
00695 if (oi == NULL) {
00696 throw TypeMismatchException("Can only copy values from interface of same type (%s vs. %s)",
00697 type(), other->type());
00698 }
00699 memcpy(data, oi->data, sizeof(FacerInterface_data_t));
00700 }
00701
00702 const char *
00703 FacerInterface::enum_tostring(const char *enumtype, int val) const
00704 {
00705 if (strcmp(enumtype, "if_facer_opmode_t") == 0) {
00706 return tostring_if_facer_opmode_t((if_facer_opmode_t)val);
00707 }
00708 throw UnknownTypeException("Unknown enum type %s", enumtype);
00709 }
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722 FacerInterface::LearnFaceMessage::LearnFaceMessage(const char * ini_name) : Message("LearnFaceMessage")
00723 {
00724 data_size = sizeof(LearnFaceMessage_data_t);
00725 data_ptr = malloc(data_size);
00726 memset(data_ptr, 0, data_size);
00727 data = (LearnFaceMessage_data_t *)data_ptr;
00728 data_ts = (message_data_ts_t *)data_ptr;
00729 strncpy(data->name, ini_name, 64);
00730 add_fieldinfo(IFT_STRING, "name", 64, data->name);
00731 }
00732
00733 FacerInterface::LearnFaceMessage::LearnFaceMessage() : Message("LearnFaceMessage")
00734 {
00735 data_size = sizeof(LearnFaceMessage_data_t);
00736 data_ptr = malloc(data_size);
00737 memset(data_ptr, 0, data_size);
00738 data = (LearnFaceMessage_data_t *)data_ptr;
00739 data_ts = (message_data_ts_t *)data_ptr;
00740 add_fieldinfo(IFT_STRING, "name", 64, data->name);
00741 }
00742
00743
00744 FacerInterface::LearnFaceMessage::~LearnFaceMessage()
00745 {
00746 free(data_ptr);
00747 }
00748
00749
00750
00751
00752 FacerInterface::LearnFaceMessage::LearnFaceMessage(const LearnFaceMessage *m) : Message("LearnFaceMessage")
00753 {
00754 data_size = m->data_size;
00755 data_ptr = malloc(data_size);
00756 memcpy(data_ptr, m->data_ptr, data_size);
00757 data = (LearnFaceMessage_data_t *)data_ptr;
00758 data_ts = (message_data_ts_t *)data_ptr;
00759 }
00760
00761
00762
00763
00764
00765
00766 char *
00767 FacerInterface::LearnFaceMessage::name() const
00768 {
00769 return data->name;
00770 }
00771
00772
00773
00774
00775
00776 size_t
00777 FacerInterface::LearnFaceMessage::maxlenof_name() const
00778 {
00779 return 64;
00780 }
00781
00782
00783
00784
00785
00786 void
00787 FacerInterface::LearnFaceMessage::set_name(const char * new_name)
00788 {
00789 strncpy(data->name, new_name, sizeof(data->name));
00790 }
00791
00792
00793
00794
00795
00796
00797 Message *
00798 FacerInterface::LearnFaceMessage::clone() const
00799 {
00800 return new FacerInterface::LearnFaceMessage(this);
00801 }
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812 FacerInterface::SetOpmodeMessage::SetOpmodeMessage(const if_facer_opmode_t ini_opmode) : Message("SetOpmodeMessage")
00813 {
00814 data_size = sizeof(SetOpmodeMessage_data_t);
00815 data_ptr = malloc(data_size);
00816 memset(data_ptr, 0, data_size);
00817 data = (SetOpmodeMessage_data_t *)data_ptr;
00818 data_ts = (message_data_ts_t *)data_ptr;
00819 data->opmode = ini_opmode;
00820 add_fieldinfo(IFT_ENUM, "opmode", 1, &data->opmode, "if_facer_opmode_t");
00821 }
00822
00823 FacerInterface::SetOpmodeMessage::SetOpmodeMessage() : Message("SetOpmodeMessage")
00824 {
00825 data_size = sizeof(SetOpmodeMessage_data_t);
00826 data_ptr = malloc(data_size);
00827 memset(data_ptr, 0, data_size);
00828 data = (SetOpmodeMessage_data_t *)data_ptr;
00829 data_ts = (message_data_ts_t *)data_ptr;
00830 add_fieldinfo(IFT_ENUM, "opmode", 1, &data->opmode, "if_facer_opmode_t");
00831 }
00832
00833
00834 FacerInterface::SetOpmodeMessage::~SetOpmodeMessage()
00835 {
00836 free(data_ptr);
00837 }
00838
00839
00840
00841
00842 FacerInterface::SetOpmodeMessage::SetOpmodeMessage(const SetOpmodeMessage *m) : Message("SetOpmodeMessage")
00843 {
00844 data_size = m->data_size;
00845 data_ptr = malloc(data_size);
00846 memcpy(data_ptr, m->data_ptr, data_size);
00847 data = (SetOpmodeMessage_data_t *)data_ptr;
00848 data_ts = (message_data_ts_t *)data_ptr;
00849 }
00850
00851
00852
00853
00854
00855
00856
00857
00858 FacerInterface::if_facer_opmode_t
00859 FacerInterface::SetOpmodeMessage::opmode() const
00860 {
00861 return data->opmode;
00862 }
00863
00864
00865
00866
00867
00868 size_t
00869 FacerInterface::SetOpmodeMessage::maxlenof_opmode() const
00870 {
00871 return 1;
00872 }
00873
00874
00875
00876
00877
00878
00879
00880 void
00881 FacerInterface::SetOpmodeMessage::set_opmode(const if_facer_opmode_t new_opmode)
00882 {
00883 data->opmode = new_opmode;
00884 }
00885
00886
00887
00888
00889
00890
00891 Message *
00892 FacerInterface::SetOpmodeMessage::clone() const
00893 {
00894 return new FacerInterface::SetOpmodeMessage(this);
00895 }
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907 FacerInterface::EnableIdentityMessage::EnableIdentityMessage(const uint32_t ini_index, const bool ini_enable) : Message("EnableIdentityMessage")
00908 {
00909 data_size = sizeof(EnableIdentityMessage_data_t);
00910 data_ptr = malloc(data_size);
00911 memset(data_ptr, 0, data_size);
00912 data = (EnableIdentityMessage_data_t *)data_ptr;
00913 data_ts = (message_data_ts_t *)data_ptr;
00914 data->index = ini_index;
00915 data->enable = ini_enable;
00916 add_fieldinfo(IFT_UINT32, "index", 1, &data->index);
00917 add_fieldinfo(IFT_BOOL, "enable", 1, &data->enable);
00918 }
00919
00920 FacerInterface::EnableIdentityMessage::EnableIdentityMessage() : Message("EnableIdentityMessage")
00921 {
00922 data_size = sizeof(EnableIdentityMessage_data_t);
00923 data_ptr = malloc(data_size);
00924 memset(data_ptr, 0, data_size);
00925 data = (EnableIdentityMessage_data_t *)data_ptr;
00926 data_ts = (message_data_ts_t *)data_ptr;
00927 add_fieldinfo(IFT_UINT32, "index", 1, &data->index);
00928 add_fieldinfo(IFT_BOOL, "enable", 1, &data->enable);
00929 }
00930
00931
00932 FacerInterface::EnableIdentityMessage::~EnableIdentityMessage()
00933 {
00934 free(data_ptr);
00935 }
00936
00937
00938
00939
00940 FacerInterface::EnableIdentityMessage::EnableIdentityMessage(const EnableIdentityMessage *m) : Message("EnableIdentityMessage")
00941 {
00942 data_size = m->data_size;
00943 data_ptr = malloc(data_size);
00944 memcpy(data_ptr, m->data_ptr, data_size);
00945 data = (EnableIdentityMessage_data_t *)data_ptr;
00946 data_ts = (message_data_ts_t *)data_ptr;
00947 }
00948
00949
00950
00951
00952
00953
00954 uint32_t
00955 FacerInterface::EnableIdentityMessage::index() const
00956 {
00957 return data->index;
00958 }
00959
00960
00961
00962
00963
00964 size_t
00965 FacerInterface::EnableIdentityMessage::maxlenof_index() const
00966 {
00967 return 1;
00968 }
00969
00970
00971
00972
00973
00974 void
00975 FacerInterface::EnableIdentityMessage::set_index(const uint32_t new_index)
00976 {
00977 data->index = new_index;
00978 }
00979
00980
00981
00982
00983
00984 bool
00985 FacerInterface::EnableIdentityMessage::is_enable() const
00986 {
00987 return data->enable;
00988 }
00989
00990
00991
00992
00993
00994 size_t
00995 FacerInterface::EnableIdentityMessage::maxlenof_enable() const
00996 {
00997 return 1;
00998 }
00999
01000
01001
01002
01003
01004 void
01005 FacerInterface::EnableIdentityMessage::set_enable(const bool new_enable)
01006 {
01007 data->enable = new_enable;
01008 }
01009
01010
01011
01012
01013
01014
01015 Message *
01016 FacerInterface::EnableIdentityMessage::clone() const
01017 {
01018 return new FacerInterface::EnableIdentityMessage(this);
01019 }
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031 FacerInterface::SetNameMessage::SetNameMessage(const uint32_t ini_index, const char * ini_name) : Message("SetNameMessage")
01032 {
01033 data_size = sizeof(SetNameMessage_data_t);
01034 data_ptr = malloc(data_size);
01035 memset(data_ptr, 0, data_size);
01036 data = (SetNameMessage_data_t *)data_ptr;
01037 data_ts = (message_data_ts_t *)data_ptr;
01038 data->index = ini_index;
01039 strncpy(data->name, ini_name, 64);
01040 add_fieldinfo(IFT_UINT32, "index", 1, &data->index);
01041 add_fieldinfo(IFT_STRING, "name", 64, data->name);
01042 }
01043
01044 FacerInterface::SetNameMessage::SetNameMessage() : Message("SetNameMessage")
01045 {
01046 data_size = sizeof(SetNameMessage_data_t);
01047 data_ptr = malloc(data_size);
01048 memset(data_ptr, 0, data_size);
01049 data = (SetNameMessage_data_t *)data_ptr;
01050 data_ts = (message_data_ts_t *)data_ptr;
01051 add_fieldinfo(IFT_UINT32, "index", 1, &data->index);
01052 add_fieldinfo(IFT_STRING, "name", 64, data->name);
01053 }
01054
01055
01056 FacerInterface::SetNameMessage::~SetNameMessage()
01057 {
01058 free(data_ptr);
01059 }
01060
01061
01062
01063
01064 FacerInterface::SetNameMessage::SetNameMessage(const SetNameMessage *m) : Message("SetNameMessage")
01065 {
01066 data_size = m->data_size;
01067 data_ptr = malloc(data_size);
01068 memcpy(data_ptr, m->data_ptr, data_size);
01069 data = (SetNameMessage_data_t *)data_ptr;
01070 data_ts = (message_data_ts_t *)data_ptr;
01071 }
01072
01073
01074
01075
01076
01077
01078 uint32_t
01079 FacerInterface::SetNameMessage::index() const
01080 {
01081 return data->index;
01082 }
01083
01084
01085
01086
01087
01088 size_t
01089 FacerInterface::SetNameMessage::maxlenof_index() const
01090 {
01091 return 1;
01092 }
01093
01094
01095
01096
01097
01098 void
01099 FacerInterface::SetNameMessage::set_index(const uint32_t new_index)
01100 {
01101 data->index = new_index;
01102 }
01103
01104
01105
01106
01107
01108 char *
01109 FacerInterface::SetNameMessage::name() const
01110 {
01111 return data->name;
01112 }
01113
01114
01115
01116
01117
01118 size_t
01119 FacerInterface::SetNameMessage::maxlenof_name() const
01120 {
01121 return 64;
01122 }
01123
01124
01125
01126
01127
01128 void
01129 FacerInterface::SetNameMessage::set_name(const char * new_name)
01130 {
01131 strncpy(data->name, new_name, sizeof(data->name));
01132 }
01133
01134
01135
01136
01137
01138
01139 Message *
01140 FacerInterface::SetNameMessage::clone() const
01141 {
01142 return new FacerInterface::SetNameMessage(this);
01143 }
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154 FacerInterface::GetNameMessage::GetNameMessage(const uint32_t ini_index) : Message("GetNameMessage")
01155 {
01156 data_size = sizeof(GetNameMessage_data_t);
01157 data_ptr = malloc(data_size);
01158 memset(data_ptr, 0, data_size);
01159 data = (GetNameMessage_data_t *)data_ptr;
01160 data_ts = (message_data_ts_t *)data_ptr;
01161 data->index = ini_index;
01162 add_fieldinfo(IFT_UINT32, "index", 1, &data->index);
01163 }
01164
01165 FacerInterface::GetNameMessage::GetNameMessage() : Message("GetNameMessage")
01166 {
01167 data_size = sizeof(GetNameMessage_data_t);
01168 data_ptr = malloc(data_size);
01169 memset(data_ptr, 0, data_size);
01170 data = (GetNameMessage_data_t *)data_ptr;
01171 data_ts = (message_data_ts_t *)data_ptr;
01172 add_fieldinfo(IFT_UINT32, "index", 1, &data->index);
01173 }
01174
01175
01176 FacerInterface::GetNameMessage::~GetNameMessage()
01177 {
01178 free(data_ptr);
01179 }
01180
01181
01182
01183
01184 FacerInterface::GetNameMessage::GetNameMessage(const GetNameMessage *m) : Message("GetNameMessage")
01185 {
01186 data_size = m->data_size;
01187 data_ptr = malloc(data_size);
01188 memcpy(data_ptr, m->data_ptr, data_size);
01189 data = (GetNameMessage_data_t *)data_ptr;
01190 data_ts = (message_data_ts_t *)data_ptr;
01191 }
01192
01193
01194
01195
01196
01197
01198 uint32_t
01199 FacerInterface::GetNameMessage::index() const
01200 {
01201 return data->index;
01202 }
01203
01204
01205
01206
01207
01208 size_t
01209 FacerInterface::GetNameMessage::maxlenof_index() const
01210 {
01211 return 1;
01212 }
01213
01214
01215
01216
01217
01218 void
01219 FacerInterface::GetNameMessage::set_index(const uint32_t new_index)
01220 {
01221 data->index = new_index;
01222 }
01223
01224
01225
01226
01227
01228
01229 Message *
01230 FacerInterface::GetNameMessage::clone() const
01231 {
01232 return new FacerInterface::GetNameMessage(this);
01233 }
01234
01235
01236
01237
01238 bool
01239 FacerInterface::message_valid(const Message *message) const
01240 {
01241 const LearnFaceMessage *m0 = dynamic_cast<const LearnFaceMessage *>(message);
01242 if ( m0 != NULL ) {
01243 return true;
01244 }
01245 const SetOpmodeMessage *m1 = dynamic_cast<const SetOpmodeMessage *>(message);
01246 if ( m1 != NULL ) {
01247 return true;
01248 }
01249 const EnableIdentityMessage *m2 = dynamic_cast<const EnableIdentityMessage *>(message);
01250 if ( m2 != NULL ) {
01251 return true;
01252 }
01253 const SetNameMessage *m3 = dynamic_cast<const SetNameMessage *>(message);
01254 if ( m3 != NULL ) {
01255 return true;
01256 }
01257 const GetNameMessage *m4 = dynamic_cast<const GetNameMessage *>(message);
01258 if ( m4 != NULL ) {
01259 return true;
01260 }
01261 return false;
01262 }
01263
01264
01265 EXPORT_INTERFACE(FacerInterface)
01266
01267
01268
01269 }