ap.cpp 36.3 KB
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 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117
#include "ap.h"

namespace ap {
    ApAgentInfo::ApAgentInfo() {
    }

    ApAgentInfo::~ApAgentInfo() {
    }

    bool ApAgentInfo::operator==(const ApAgentInfo& rhs) const {
        if (this == &rhs) {
            return true;
        }
        if (agentId != rhs.agentId) {
            return false;
        }
        if (agentDn != rhs.agentDn) {
            return false;
        }
        if (agentPwd != rhs.agentPwd) {
            return false;
        }
        if (statusChangetype != rhs.statusChangetype) {
            return false;
        }
        if (autoAnswer != rhs.autoAnswer) {
            return false;
        }
        if (fcSignin != rhs.fcSignin) {
            return false;
        }
        if (skills != rhs.skills) {
            return false;
        }
        if (proxyname != rhs.proxyname) {
            return false;
        }
        if (proxyname_old != rhs.proxyname_old) {
            return false;
        }
        if (handle != rhs.handle) {
            return false;
        }
        if (flag != rhs.flag) {
            return false;
        }
        return true;
    }

    bool ApAgentInfo::operator!=(const ApAgentInfo& rhs) const {
        return !(*this == rhs);
    }

    bool ApAgentInfo::operator< (const ApAgentInfo& rhs) const {
        if (this == &rhs) {
            return false;
        }

        if (agentId < rhs.agentId) {
            return true;
        }
        else if (rhs.agentId < agentId) {
            return false;
        }

        if (agentDn < rhs.agentDn) {
            return true;
        }
        else if (rhs.agentDn < agentDn) {
            return false;
        }

        if (agentPwd < rhs.agentPwd) {
            return true;
        }
        else if (rhs.agentPwd < agentPwd) {
            return false;
        }

        if (statusChangetype < rhs.statusChangetype) {
            return true;
        }
        else if (rhs.statusChangetype < statusChangetype) {
            return false;
        }

        if (autoAnswer < rhs.autoAnswer) {
            return true;
        }
        else if (rhs.autoAnswer < autoAnswer) {
            return false;
        }

        if (fcSignin < rhs.fcSignin) {
            return true;
        }
        else if (rhs.fcSignin < fcSignin) {
            return false;
        }

        if (skills < rhs.skills) {
            return true;
        }
        else if (rhs.skills < skills) {
            return false;
        }

        if (proxyname < rhs.proxyname) {
            return true;
        }
        else if (rhs.proxyname < proxyname) {
            return false;
        }

        if (proxyname_old < rhs.proxyname_old) {
            return true;
        }
        else if (rhs.proxyname_old < proxyname_old) {
            return false;
        }

        if (handle < rhs.handle) {
            return true;
        }
        else if (rhs.handle < handle) {
            return false;
        }

        if (flag < rhs.flag) {
            return true;
        }
        else if (rhs.flag < flag) {
            return false;
        }

        return false;
    }

    int32_t ApAgentInfo::read(char *request, int32_t request_len, bgcc::SharedPointer<bgcc::IProtocol> proto){
        int32_t ret = 0;
        std::string fname;
        int32_t nread = 0;
        bgcc::DataTypeID ftype;
        bgcc::FieldIDType fid;

        ret = proto->readStructBegin(OFFSET_PTR(request, nread), request_len - nread, fname);
        if (ret < 0) { return ret; }
        nread += ret;

        while(true) {
            ret = proto->readFieldBegin(OFFSET_PTR(request, nread), request_len - nread, fname, ftype, fid);
            if(ret < 0) { return ret; }
            nread += ret;

            if(ftype == bgcc::IDSTOP){
                break;
            }

            switch(fid) {
            case 1:
                ret = proto->readString(OFFSET_PTR(request, nread), request_len - nread, agentId);
                if (ret < 0) { return ret; }
                nread += ret;
                break;
            case 2:
                ret = proto->readString(OFFSET_PTR(request, nread), request_len - nread, agentDn);
                if (ret < 0) { return ret; }
                nread += ret;
                break;
            case 3:
                ret = proto->readString(OFFSET_PTR(request, nread), request_len - nread, agentPwd);
                if (ret < 0) { return ret; }
                nread += ret;
                break;
            case 4:
                int32_t ele_var1;
                ret = proto->readInt32(OFFSET_PTR(request, nread), request_len - nread, ele_var1);
                if (ret < 0) { return ret; }
                nread += ret;
                statusChangetype = ele_var1;
                break;
            case 5:
                ret = proto->readBool(OFFSET_PTR(request, nread), request_len - nread, autoAnswer);
                if (ret < 0) { return ret; }
                nread += ret;
                break;
            case 6:
                ret = proto->readBool(OFFSET_PTR(request, nread), request_len - nread, fcSignin);
                if (ret < 0) { return ret; }
                nread += ret;
                break;
            case 7:
                ret = proto->readString(OFFSET_PTR(request, nread), request_len - nread, skills);
                if (ret < 0) { return ret; }
                nread += ret;
                break;
            case 8:
                ret = proto->readString(OFFSET_PTR(request, nread), request_len - nread, proxyname);
                if (ret < 0) { return ret; }
                nread += ret;
                break;
            case 9:
                ret = proto->readString(OFFSET_PTR(request, nread), request_len - nread, proxyname_old);
                if (ret < 0) { return ret; }
                nread += ret;
                break;
            case 10:
                ret = proto->readInt64(OFFSET_PTR(request, nread), request_len - nread, handle);
                if (ret < 0) { return ret; }
                nread += ret;
                break;
            case 11:
                ret = proto->readInt32(OFFSET_PTR(request, nread), request_len - nread, flag);
                if (ret < 0) { return ret; }
                nread += ret;
                break;
            }
            ret = proto->readFieldEnd();
            if (ret < 0) { return ret; }
        }

        ret = proto->readStructEnd();
        if (ret < 0) { return ret; }
        return nread;
    }

    int32_t ApAgentInfo::write(bgcc::SharedPointer<bgcc::IProtocol> proto) const {
        int32_t ret = 0;

        ret = proto->writeStructBegin("ApAgentInfo");
        if (ret < 0) { return ret; }

        ret = proto->writeFieldBegin("agentId", bgcc::IDSTR, 1);
        if (ret < 0) { return ret; }
        ret = proto->writeString(agentId);
        if (ret < 0) { return ret; }
        ret = proto->writeFieldEnd();
        if (ret < 0) { return ret; }

        ret = proto->writeFieldBegin("agentDn", bgcc::IDSTR, 2);
        if (ret < 0) { return ret; }
        ret = proto->writeString(agentDn);
        if (ret < 0) { return ret; }
        ret = proto->writeFieldEnd();
        if (ret < 0) { return ret; }

        ret = proto->writeFieldBegin("agentPwd", bgcc::IDSTR, 3);
        if (ret < 0) { return ret; }
        ret = proto->writeString(agentPwd);
        if (ret < 0) { return ret; }
        ret = proto->writeFieldEnd();
        if (ret < 0) { return ret; }

        ret = proto->writeFieldBegin("statusChangetype", bgcc::IDINT32, 4);
        if (ret < 0) { return ret; }
        ret = proto->writeInt32(statusChangetype.get_value());
        if (ret < 0) { return ret; }
        ret = proto->writeFieldEnd();
        if (ret < 0) { return ret; }

        ret = proto->writeFieldBegin("autoAnswer", bgcc::IDBOOL, 5);
        if (ret < 0) { return ret; }
        ret = proto->writeBool(autoAnswer);
        if (ret < 0) { return ret; }
        ret = proto->writeFieldEnd();
        if (ret < 0) { return ret; }

        ret = proto->writeFieldBegin("fcSignin", bgcc::IDBOOL, 6);
        if (ret < 0) { return ret; }
        ret = proto->writeBool(fcSignin);
        if (ret < 0) { return ret; }
        ret = proto->writeFieldEnd();
        if (ret < 0) { return ret; }

        ret = proto->writeFieldBegin("skills", bgcc::IDSTR, 7);
        if (ret < 0) { return ret; }
        ret = proto->writeString(skills);
        if (ret < 0) { return ret; }
        ret = proto->writeFieldEnd();
        if (ret < 0) { return ret; }

        ret = proto->writeFieldBegin("proxyname", bgcc::IDSTR, 8);
        if (ret < 0) { return ret; }
        ret = proto->writeString(proxyname);
        if (ret < 0) { return ret; }
        ret = proto->writeFieldEnd();
        if (ret < 0) { return ret; }

        ret = proto->writeFieldBegin("proxyname_old", bgcc::IDSTR, 9);
        if (ret < 0) { return ret; }
        ret = proto->writeString(proxyname_old);
        if (ret < 0) { return ret; }
        ret = proto->writeFieldEnd();
        if (ret < 0) { return ret; }

        ret = proto->writeFieldBegin("handle", bgcc::IDINT64, 10);
        if (ret < 0) { return ret; }
        ret = proto->writeInt64(handle);
        if (ret < 0) { return ret; }
        ret = proto->writeFieldEnd();
        if (ret < 0) { return ret; }

        ret = proto->writeFieldBegin("flag", bgcc::IDINT32, 11);
        if (ret < 0) { return ret; }
        ret = proto->writeInt32(flag);
        if (ret < 0) { return ret; }
        ret = proto->writeFieldEnd();
        if (ret < 0) { return ret; }

        ret = proto->writeFieldStop();
        if (ret < 0) { return ret; }

        return proto->writeStructEnd();
    }
    apapi_ReLoadConfig_args::apapi_ReLoadConfig_args() {
    }

    apapi_ReLoadConfig_args::~apapi_ReLoadConfig_args() {
    }

    bool apapi_ReLoadConfig_args::operator==(const apapi_ReLoadConfig_args& rhs) const {
        if (this == &rhs) {
            return true;
        }
        return true;
    }

    bool apapi_ReLoadConfig_args::operator!=(const apapi_ReLoadConfig_args& rhs) const {
        return !(*this == rhs);
    }

    bool apapi_ReLoadConfig_args::operator< (const apapi_ReLoadConfig_args& rhs) const {
        if (this == &rhs) {
            return false;
        }
        return true;
    }

    int32_t apapi_ReLoadConfig_args::read(char* request, int32_t request_len, bgcc::SharedPointer<bgcc::IProtocol> proto) {
        int32_t ret = 0; 
        std::string fname;
        int32_t nread = 0;
        bgcc::DataTypeID ftype;
        bgcc::FieldIDType fid; 

        ret = proto->readStructBegin(OFFSET_PTR(request, nread), request_len - nread, fname);
        if (ret < 0) { return ret; }
        nread += ret;

        while (true) {
            ret = proto->readFieldBegin(OFFSET_PTR(request, nread), request_len - nread, fname, ftype, fid);
            if (ret < 0) { return ret; }
            nread += ret;

            if (ftype == bgcc::IDSTOP) {
                break;
            }

            ret = proto->readFieldEnd();
            if (ret < 0) { return ret; }
        }
        ret = proto->readStructEnd();
        if (ret < 0) { return ret; }
        return nread;
    }

    apapi_GetAgents_args::apapi_GetAgents_args() {
    }

    apapi_GetAgents_args::~apapi_GetAgents_args() {
    }

    bool apapi_GetAgents_args::operator==(const apapi_GetAgents_args& rhs) const {
        if (this == &rhs) {
            return true;
        }
        return true;
    }

    bool apapi_GetAgents_args::operator!=(const apapi_GetAgents_args& rhs) const {
        return !(*this == rhs);
    }

    bool apapi_GetAgents_args::operator< (const apapi_GetAgents_args& rhs) const {
        if (this == &rhs) {
            return false;
        }
        return true;
    }

    int32_t apapi_GetAgents_args::read(char* request, int32_t request_len, bgcc::SharedPointer<bgcc::IProtocol> proto) {
        int32_t ret = 0; 
        std::string fname;
        int32_t nread = 0;
        bgcc::DataTypeID ftype;
        bgcc::FieldIDType fid; 

        ret = proto->readStructBegin(OFFSET_PTR(request, nread), request_len - nread, fname);
        if (ret < 0) { return ret; }
        nread += ret;

        while (true) {
            ret = proto->readFieldBegin(OFFSET_PTR(request, nread), request_len - nread, fname, ftype, fid);
            if (ret < 0) { return ret; }
            nread += ret;

            if (ftype == bgcc::IDSTOP) {
                break;
            }

            ret = proto->readFieldEnd();
            if (ret < 0) { return ret; }
        }
        ret = proto->readStructEnd();
        if (ret < 0) { return ret; }
        return nread;
    }

    apapi_ReLoadConfig_pargs::~apapi_ReLoadConfig_pargs() {
    }

    int32_t apapi_ReLoadConfig_pargs::write(bgcc::SharedPointer<bgcc::IProtocol> proto) const {
        int32_t ret = 0;
        ret = proto->writeStructBegin("apapi_ReLoadConfig_pargs");
        if (ret < 0) { return ret; }

        ret = proto->writeFieldStop();
        if (ret < 0) { return ret; }
        ret = proto->writeStructEnd();
        if (ret < 0) { return ret; }
        return ret;
    };

    apapi_GetAgents_pargs::~apapi_GetAgents_pargs() {
    }

    int32_t apapi_GetAgents_pargs::write(bgcc::SharedPointer<bgcc::IProtocol> proto) const {
        int32_t ret = 0;
        ret = proto->writeStructBegin("apapi_GetAgents_pargs");
        if (ret < 0) { return ret; }

        ret = proto->writeFieldStop();
        if (ret < 0) { return ret; }
        ret = proto->writeStructEnd();
        if (ret < 0) { return ret; }
        return ret;
    };

    apapi_ReLoadConfig_result::apapi_ReLoadConfig_result() {
    }

    apapi_ReLoadConfig_result::~apapi_ReLoadConfig_result() {
    }

    bool apapi_ReLoadConfig_result::operator==(const apapi_ReLoadConfig_result& rhs) const {
        if (this == &rhs) {
            return true;
        }
        if (return_value != rhs.return_value) {
            return false;
        }
        return true;
    }

    bool apapi_ReLoadConfig_result::operator!=(const apapi_ReLoadConfig_result& rhs) const {
        return !(*this == rhs);
    }

    bool apapi_ReLoadConfig_result::operator< (const apapi_ReLoadConfig_result& rhs) const {
        if (this == &rhs) {
            return false;
        }
        if (!(return_value < rhs.return_value)) {
            return false;
        }
        return true;
    }

    int32_t apapi_ReLoadConfig_result::write(bgcc::SharedPointer<bgcc::IProtocol> proto) const {
        int32_t ret = 0;
        ret = proto->writeStructBegin("apapi_ReLoadConfig_result");
        if (ret < 0) { return ret; }

        ret = proto->writeFieldBegin("return_value", bgcc::IDBOOL, 0);
        if (ret < 0) { return ret; }
        ret = proto->writeBool(return_value);
        if (ret < 0) { return ret; }
        ret = proto->writeFieldEnd();
        if (ret < 0) { return ret; }

        ret = proto->writeFieldStop();
        if (ret < 0) { return ret; }

        return proto->writeStructEnd();
    }

    apapi_GetAgents_result::apapi_GetAgents_result() {
    }

    apapi_GetAgents_result::~apapi_GetAgents_result() {
    }

    bool apapi_GetAgents_result::operator==(const apapi_GetAgents_result& rhs) const {
        if (this == &rhs) {
            return true;
        }
        if (return_value != rhs.return_value) {
            return false;
        }
        if (agentInfoList != rhs.agentInfoList) {
            return false;
        }
        return true;
    }

    bool apapi_GetAgents_result::operator!=(const apapi_GetAgents_result& rhs) const {
        return !(*this == rhs);
    }

    bool apapi_GetAgents_result::operator< (const apapi_GetAgents_result& rhs) const {
        if (this == &rhs) {
            return false;
        }
        if (!(return_value < rhs.return_value)) {
            return false;
        }
        if (!(agentInfoList < rhs.agentInfoList)) {
            return false;
        }
        return true;
    }

    int32_t apapi_GetAgents_result::write(bgcc::SharedPointer<bgcc::IProtocol> proto) const {
        int32_t ret = 0;
        ret = proto->writeStructBegin("apapi_GetAgents_result");
        if (ret < 0) { return ret; }

        ret = proto->writeFieldBegin("return_value", bgcc::IDBOOL, 0);
        if (ret < 0) { return ret; }
        ret = proto->writeBool(return_value);
        if (ret < 0) { return ret; }
        ret = proto->writeFieldEnd();
        if (ret < 0) { return ret; }

        ret = proto->writeFieldBegin("agentInfoList", bgcc::IDLIST, 1);
        if (ret < 0) { return ret; }
        ret = proto->writeListBegin(bgcc::IDSTRUCT, agentInfoList.size());
        if (ret < 0) { return ret; }
        std::vector<ApAgentInfo> ::const_iterator citr_var2;
        for (citr_var2 = agentInfoList.begin(); citr_var2 != agentInfoList.end(); ++citr_var2) {
            ret = (*citr_var2).write(proto);
            if (ret < 0) { return ret; }
        }
        ret = proto->writeListEnd();
        if (ret < 0) { return ret; }
        ret = proto->writeFieldEnd();
        if (ret < 0) { return ret; }

        ret = proto->writeFieldStop();
        if (ret < 0) { return ret; }

        return proto->writeStructEnd();
    }

    apapi_ReLoadConfig_presult::~apapi_ReLoadConfig_presult() {
    }

    int32_t apapi_ReLoadConfig_presult::read(char *request, int32_t request_len, bgcc::SharedPointer<bgcc::IProtocol> proto) const {
        int32_t ret=0;
        int32_t nread=0;
        std::string fname;
        bgcc::DataTypeID ftype;
        bgcc::FieldIDType fid; 

        ret = proto->readStructBegin(OFFSET_PTR(request, nread), request_len - nread, fname);
        if (ret < 0) { return ret; }
        nread+=ret;

        while(true) {
            ret = proto->readFieldBegin(OFFSET_PTR(request, nread), request_len - nread, fname, ftype, fid);
            if (ret < 0) { return ret; }
            nread+=ret;

            if (ftype == bgcc::IDSTOP) {
                break;
            }
            switch(fid) {
            case 0:
                ret = proto->readBool(OFFSET_PTR(request, nread), request_len - nread, (*(return_value)));
                if (ret < 0) { return ret; }
                nread += ret;
                break;
            default:
                break;
            }

            ret = proto->readFieldEnd();
            if (ret < 0) { return ret; }
            nread+=ret; 
        }

        ret=proto->readStructEnd();
        if (ret < 0) { return ret; }
        nread+=ret; 

        return nread;
    }

    apapi_GetAgents_presult::~apapi_GetAgents_presult() {
    }

    int32_t apapi_GetAgents_presult::read(char *request, int32_t request_len, bgcc::SharedPointer<bgcc::IProtocol> proto) const {
        int32_t ret=0;
        int32_t nread=0;
        std::string fname;
        bgcc::DataTypeID ftype;
        bgcc::FieldIDType fid; 

        ret = proto->readStructBegin(OFFSET_PTR(request, nread), request_len - nread, fname);
        if (ret < 0) { return ret; }
        nread+=ret;

        while(true) {
            ret = proto->readFieldBegin(OFFSET_PTR(request, nread), request_len - nread, fname, ftype, fid);
            if (ret < 0) { return ret; }
            nread+=ret;

            if (ftype == bgcc::IDSTOP) {
                break;
            }
            switch(fid) {
            case 0:
                ret = proto->readBool(OFFSET_PTR(request, nread), request_len - nread, (*(return_value)));
                if (ret < 0) { return ret; }
                nread += ret;
                break;
            case 1:
                (*(agentInfoList)).clear();

                int32_t size_var3;
                bgcc::DataTypeID etype_var4;

                ret = proto->readListBegin(OFFSET_PTR(request, nread), request_len - nread, etype_var4, size_var3);
                if (ret < 0) { return ret; }
                nread += ret;

                (*(agentInfoList)).reserve(size_var3);
                for(int32_t i = 0; i < size_var3; ++i) {
                    ApAgentInfo value_var5;
                    ret = value_var5.read(OFFSET_PTR(request, nread), request_len - nread, proto);
                    if (ret < 0) { return ret; }
                    nread += ret;
                    (*(agentInfoList)).push_back(value_var5);
                }

                ret = proto->readListEnd();
                if (ret < 0) { return ret; }
                break;
            default:
                break;
            }

            ret = proto->readFieldEnd();
            if (ret < 0) { return ret; }
            nread+=ret; 
        }

        ret=proto->readStructEnd();
        if (ret < 0) { return ret; }
        nread+=ret; 

        return nread;
    }

    apapiProxy::apapiProxy(
        bgcc::ServerInfo serverinfo,
        int32_t maxConn,
        bgcc::ServiceManager* mgr,
        int32_t tryCount,
        int32_t tryInterval) :
        bgcc::BaseProxy(serverinfo, maxConn, true, mgr, tryCount, tryInterval){
            _whoami = "global.ap.apapi";
    }

    apapiProxy::apapiProxy(
        bgcc::ServerInfo serverinfo,
        bgcc::ServiceManager* mgr,
        int32_t tryCount,
        int32_t tryInterval) :
        bgcc::BaseProxy(serverinfo, 1, false, mgr, tryCount, tryInterval){
            _whoami = "global.ap.apapi";
    }

    apapiProxy::apapiProxy(const std::string& proxy_name, int32_t tryCount, int32_t tryInterval) :
        bgcc::BaseProxy(bgcc::ServerInfo("", 0), 0, true, NULL, tryCount, tryInterval){
            _whoami = "global.ap.apapi";
            _use_existing_socket  = true;
            _name=proxy_name;
    }

    bool apapiProxy::ReLoadConfig(bool /*last*/) {
        bool return_value = false;
        int tryCount = 0;
        do{
            bgcc::SharedPointer<bgcc::ConnInfo> conn=get_Conn();
            if(conn.is_valid()&&conn->proto.is_valid()){
                send_ReLoadConfig(_seqid, conn);
                if(get_errno()==0){
                    return_value = recv_ReLoadConfig(conn);
                    free_Conn(conn, get_errno());
                }
            }
            else{
                set_errno(-1);
            }
        }while(!_use_existing_socket&&tryCount++<_tryCount&&get_errno()!=0);

        return return_value;
    }

    void apapiProxy::send_ReLoadConfig(int32_t seqid, bgcc::SharedPointer<bgcc::ConnInfo> conn) {
        bgcc::SharedPointer<bgcc::IProtocol> proto = conn->proto;
        int32_t ret_code = 0;
        set_errno(ret_code);

        ret_code = proto->writeMessageBegin(_whoami.c_str(), "ReLoadConfig", bgcc::CALL, seqid);
        if (ret_code < 0) { set_errno(ret_code); return;}

        ret_code = proto->writeString(get_name());
        if (ret_code < 0) { set_errno(ret_code); return;}

        apapi_ReLoadConfig_pargs pargs;
        ret_code = pargs.write(proto);
        if (ret_code < 0) { set_errno(ret_code); return;}

        proto->writeMessageEnd();
        if (ret_code < 0) { set_errno(ret_code); return;}
    }

    bool apapiProxy::recv_ReLoadConfig(bgcc::SharedPointer<bgcc::ConnInfo> conn) {
        bool ret_val = false;
        bgcc::SharedPointer<bgcc::IProtocol> proto=conn->proto;
        int32_t ret_code=0;
        std::string fname;
        bgcc::MsgTypeID  msg_type=bgcc::CALL;
        int32_t msg_seqid=0;
        char *read_buf=NULL;
        int32_t read_buf_len = 0;
        apapi_ReLoadConfig_presult presult;
        set_errno(ret_code);

        if((ret_code=proto->readMessageBegin(&read_buf, read_buf_len, fname, msg_type, msg_seqid, conn->param))>HEAD_SIZE
            &&msg_type==bgcc::REPLY
            &&fname=="ReLoadConfig"){
            presult.return_value = &ret_val;
            ret_code = presult.read(OFFSET_PTR(read_buf, ret_code), read_buf_len - ret_code, proto);
            if(ret_code>0) { ret_code=proto->readMessageEnd();}
        }
        else{
            ret_code=-1;
        }
        set_errno(ret_code);
        return ret_val;
    }

    bool apapiProxy::GetAgents(ApAgentInfoListT& agentInfoList, bool /*last*/) {
        bool return_value = false;
        int tryCount = 0;
        do{
            bgcc::SharedPointer<bgcc::ConnInfo> conn=get_Conn();
            if(conn.is_valid()&&conn->proto.is_valid()){
                send_GetAgents(_seqid, conn);
                if(get_errno()==0){
                    return_value = recv_GetAgents(agentInfoList, conn);
                    free_Conn(conn, get_errno());
                }
            }
            else{
                set_errno(-1);
            }
        }while(!_use_existing_socket&&tryCount++<_tryCount&&get_errno()!=0);

        return return_value;
    }

    void apapiProxy::send_GetAgents(int32_t seqid, bgcc::SharedPointer<bgcc::ConnInfo> conn) {
        bgcc::SharedPointer<bgcc::IProtocol> proto = conn->proto;
        int32_t ret_code = 0;
        set_errno(ret_code);

        ret_code = proto->writeMessageBegin(_whoami.c_str(), "GetAgents", bgcc::CALL, seqid);
        if (ret_code < 0) { set_errno(ret_code); return;}

        ret_code = proto->writeString(get_name());
        if (ret_code < 0) { set_errno(ret_code); return;}

        apapi_GetAgents_pargs pargs;
        ret_code = pargs.write(proto);
        if (ret_code < 0) { set_errno(ret_code); return;}

        proto->writeMessageEnd();
        if (ret_code < 0) { set_errno(ret_code); return;}
    }

    bool apapiProxy::recv_GetAgents(ApAgentInfoListT& agentInfoList, bgcc::SharedPointer<bgcc::ConnInfo> conn) {
        bool ret_val = false;
        bgcc::SharedPointer<bgcc::IProtocol> proto=conn->proto;
        int32_t ret_code=0;
        std::string fname;
        bgcc::MsgTypeID  msg_type=bgcc::CALL;
        int32_t msg_seqid=0;
        char *read_buf=NULL;
        int32_t read_buf_len = 0;
        apapi_GetAgents_presult presult;
        set_errno(ret_code);

        if((ret_code=proto->readMessageBegin(&read_buf, read_buf_len, fname, msg_type, msg_seqid, conn->param))>HEAD_SIZE
            &&msg_type==bgcc::REPLY
            &&fname=="GetAgents"){
            presult.return_value = &ret_val;
            presult.agentInfoList = &agentInfoList;
            ret_code = presult.read(OFFSET_PTR(read_buf, ret_code), read_buf_len - ret_code, proto);
            if(ret_code>0) { ret_code=proto->readMessageEnd();}
        }
        else{
            ret_code=-1;
        }
        set_errno(ret_code);
        return ret_val;
    }

    SSLapapiProxy::SSLapapiProxy(
        bgcc::ServerInfo serverinfo,
        int32_t maxConn,
        bgcc::ServiceManager* mgr,
        int32_t tryCount,
        int32_t tryInterval) :
        bgcc::SSLBaseProxy(serverinfo, maxConn, true, mgr, tryCount, tryInterval){
            _whoami = "global.ap.apapi";
    }

    SSLapapiProxy::SSLapapiProxy(
        bgcc::ServerInfo serverinfo,
        bgcc::ServiceManager* mgr,
        int32_t tryCount,
        int32_t tryInterval) :
        bgcc::SSLBaseProxy(serverinfo, 1, false, mgr, tryCount, tryInterval){
            _whoami = "global.ap.apapi";
    }

    SSLapapiProxy::SSLapapiProxy(const std::string& proxy_name, int32_t tryCount, int32_t tryInterval) :
        bgcc::SSLBaseProxy(bgcc::ServerInfo("", 0), 0, true, NULL, tryCount, tryInterval){
            _whoami = "global.ap.apapi";
            _use_existing_socket  = true;
            _name=proxy_name;
    }

    bool SSLapapiProxy::ReLoadConfig(bool /*last*/) {
        bool return_value = false;
        int tryCount = 0;
        do{
            bgcc::SharedPointer<bgcc::ConnInfo> conn=get_Conn();
            if(conn.is_valid()&&conn->proto.is_valid()){
                send_ReLoadConfig(_seqid, conn);
                if(get_errno()==0){
                    return_value = recv_ReLoadConfig(conn);
                    free_Conn(conn, get_errno());
                }
            }
            else{
                set_errno(-1);
            }
        }while(!_use_existing_socket&&tryCount++<_tryCount&&get_errno()!=0);

        return return_value;
    }

    void SSLapapiProxy::send_ReLoadConfig(int32_t seqid, bgcc::SharedPointer<bgcc::ConnInfo> conn) {
        bgcc::SharedPointer<bgcc::IProtocol> proto = conn->proto;
        int32_t ret_code = 0;
        set_errno(ret_code);

        ret_code = proto->writeMessageBegin(_whoami.c_str(), "ReLoadConfig", bgcc::CALL, seqid);
        if (ret_code < 0) { set_errno(ret_code); return;}

        ret_code = proto->writeString(get_name());
        if (ret_code < 0) { set_errno(ret_code); return;}

        apapi_ReLoadConfig_pargs pargs;
        ret_code = pargs.write(proto);
        if (ret_code < 0) { set_errno(ret_code); return;}

        proto->writeMessageEnd();
        if (ret_code < 0) { set_errno(ret_code); return;}
    }

    bool SSLapapiProxy::recv_ReLoadConfig(bgcc::SharedPointer<bgcc::ConnInfo> conn) {
        bool ret_val = false;
        bgcc::SharedPointer<bgcc::IProtocol> proto=conn->proto;
        int32_t ret_code=0;
        std::string fname;
        bgcc::MsgTypeID  msg_type=bgcc::CALL;
        int32_t msg_seqid=0;
        char *read_buf=NULL;
        int32_t read_buf_len = 0;
        apapi_ReLoadConfig_presult presult;
        set_errno(ret_code);

        if((ret_code=proto->readMessageBegin(&read_buf, read_buf_len, fname, msg_type, msg_seqid, conn->param))>HEAD_SIZE
            &&msg_type==bgcc::REPLY
            &&fname=="ReLoadConfig"){
            presult.return_value = &ret_val;
            ret_code = presult.read(OFFSET_PTR(read_buf, ret_code), read_buf_len - ret_code, proto);
            if(ret_code>0) { ret_code=proto->readMessageEnd();}
        }
        else{
            ret_code=-1;
        }
        set_errno(ret_code);
        return ret_val;
    }

    bool SSLapapiProxy::GetAgents(ApAgentInfoListT& agentInfoList, bool /*last*/) {
        bool return_value = false;
        int tryCount = 0;
        do{
            bgcc::SharedPointer<bgcc::ConnInfo> conn=get_Conn();
            if(conn.is_valid()&&conn->proto.is_valid()){
                send_GetAgents(_seqid, conn);
                if(get_errno()==0){
                    return_value = recv_GetAgents(agentInfoList, conn);
                    free_Conn(conn, get_errno());
                }
            }
            else{
                set_errno(-1);
            }
        }while(!_use_existing_socket&&tryCount++<_tryCount&&get_errno()!=0);

        return return_value;
    }

    void SSLapapiProxy::send_GetAgents(int32_t seqid, bgcc::SharedPointer<bgcc::ConnInfo> conn) {
        bgcc::SharedPointer<bgcc::IProtocol> proto = conn->proto;
        int32_t ret_code = 0;
        set_errno(ret_code);

        ret_code = proto->writeMessageBegin(_whoami.c_str(), "GetAgents", bgcc::CALL, seqid);
        if (ret_code < 0) { set_errno(ret_code); return;}

        ret_code = proto->writeString(get_name());
        if (ret_code < 0) { set_errno(ret_code); return;}

        apapi_GetAgents_pargs pargs;
        ret_code = pargs.write(proto);
        if (ret_code < 0) { set_errno(ret_code); return;}

        proto->writeMessageEnd();
        if (ret_code < 0) { set_errno(ret_code); return;}
    }

    bool SSLapapiProxy::recv_GetAgents(ApAgentInfoListT& agentInfoList, bgcc::SharedPointer<bgcc::ConnInfo> conn) {
        bool ret_val = false;
        bgcc::SharedPointer<bgcc::IProtocol> proto=conn->proto;
        int32_t ret_code=0;
        std::string fname;
        bgcc::MsgTypeID  msg_type=bgcc::CALL;
        int32_t msg_seqid=0;
        char *read_buf=NULL;
        int32_t read_buf_len = 0;
        apapi_GetAgents_presult presult;
        set_errno(ret_code);

        if((ret_code=proto->readMessageBegin(&read_buf, read_buf_len, fname, msg_type, msg_seqid, conn->param))>HEAD_SIZE
            &&msg_type==bgcc::REPLY
            &&fname=="GetAgents"){
            presult.return_value = &ret_val;
            presult.agentInfoList = &agentInfoList;
            ret_code = presult.read(OFFSET_PTR(read_buf, ret_code), read_buf_len - ret_code, proto);
            if(ret_code>0) { ret_code=proto->readMessageEnd();}
        }
        else{
            ret_code=-1;
        }
        set_errno(ret_code);
        return ret_val;
    }

    apapiProcessor::apapiProcessor(bgcc::SharedPointer<apapi> intf) :
        bgcc::BaseProcessor(), __intf(intf) {
        __fun_map["ReLoadConfig"] = &apapiProcessor::do_ReLoadConfig;
        __fun_map["GetAgents"] = &apapiProcessor::do_GetAgents;
    }

    int32_t apapiProcessor::process(char* request, int32_t request_len, bgcc::SharedPointer<bgcc::IProtocol> proto) {
        int32_t ret = 0;
        bgcc::MsgTypeID mtype;
        int32_t seqid;
        std::string fname;
        int32_t nread = 0;
        ret = proto->readMessageBegin(&request, request_len, fname, mtype, seqid);
        if (ret < 0) { return ret;}
        nread += ret;
        if (mtype != ::bgcc::CALL){
            return -1;
        }
        return do_function__(OFFSET_PTR(request, nread), request_len-nread, proto, fname, seqid);
    }

    std::string apapiProcessor::get_name() const {
        return "global.ap.apapi";
    }

    int32_t apapiProcessor::do_function__(char* request, int32_t request_len, bgcc::SharedPointer<bgcc::IProtocol> proto, 
        const std::string& fname, int32_t seqid) {
        std::map<std::string, do_function_ptr>::iterator it;
        it = __fun_map.find(fname);
        if (it == __fun_map.end()) {
            return bgcc::BaseProcessor::do_function__(request, request_len, proto, fname, seqid);
        }

        return (this->*(it->second))(request, request_len, proto, seqid);
    }

    int32_t apapiProcessor::do_ReLoadConfig(char* request, int32_t request_len, bgcc::SharedPointer<bgcc::IProtocol> proto, int32_t seqid) {
        int32_t ret = 0;
        std::map<std::string, std::string> map;

        int32_t proxy_name_len = INT32(request);
        std::string proxy_name(OFFSET_PTR(request, LENGTH_SIZE), proxy_name_len);
        request+=(LENGTH_SIZE+proxy_name_len);
        request_len-=(proxy_name_len+LENGTH_SIZE);
        typedef bgcc::SharedPointer<bgcc::ITransport> ITransSharedPointer;

        ITransSharedPointer ITransptr= proto->getTransport();
        bgcc::ServerPeerSocket* pServer = dynamic_cast<bgcc::ServerPeerSocket*>(ITransptr.get());
        if (pServer) {
            typedef bgcc::SharedPointer<bgcc::PeerInfo> PeerInfoSharedPointer;
            PeerInfoSharedPointer peerptr = pServer->GetPeerInfo();
            map[PEER_IP] =  peerptr->GetHost();
            std::string strPort;
            std::stringstream stream;
            stream<<peerptr->GetPort();
            stream>>strPort;
            map[PEER_PORT]= strPort;
        }
        map[PROXY_NAME] = proxy_name;

        apapi_ReLoadConfig_args args;
        ret = args.read(request, request_len, proto);
        if (ret < 0) { return ret;}

        request += ret;
        request_len -= ret;

        ret = proto->readMessageEnd();
        if (ret < 0) { return ret; }

        apapi_ReLoadConfig_result result;
        result.return_value = __intf->ReLoadConfig(map);
        ret = proto->writeMessageBegin("global.ap.apapi", "ReLoadConfig", ::bgcc::REPLY, seqid);
        if (ret < 0) { return ret;}
        ret = result.write(proto);
        if (ret < 0) { return ret; }

        ret = proto->writeMessageEnd();
        return ret;
    }

    int32_t apapiProcessor::do_GetAgents(char* request, int32_t request_len, bgcc::SharedPointer<bgcc::IProtocol> proto, int32_t seqid) {
        int32_t ret = 0;
        std::map<std::string, std::string> map;

        int32_t proxy_name_len = INT32(request);
        std::string proxy_name(OFFSET_PTR(request, LENGTH_SIZE), proxy_name_len);
        request+=(LENGTH_SIZE+proxy_name_len);
        request_len-=(proxy_name_len+LENGTH_SIZE);
        typedef bgcc::SharedPointer<bgcc::ITransport> ITransSharedPointer;

        ITransSharedPointer ITransptr= proto->getTransport();
        bgcc::ServerPeerSocket* pServer = dynamic_cast<bgcc::ServerPeerSocket*>(ITransptr.get());
        if (pServer) {
            typedef bgcc::SharedPointer<bgcc::PeerInfo> PeerInfoSharedPointer;
            PeerInfoSharedPointer peerptr = pServer->GetPeerInfo();
            map[PEER_IP] =  peerptr->GetHost();
            std::string strPort;
            std::stringstream stream;
            stream<<peerptr->GetPort();
            stream>>strPort;
            map[PEER_PORT]= strPort;
        }
        map[PROXY_NAME] = proxy_name;

        apapi_GetAgents_args args;
        ret = args.read(request, request_len, proto);
        if (ret < 0) { return ret;}

        request += ret;
        request_len -= ret;

        ret = proto->readMessageEnd();
        if (ret < 0) { return ret; }

        apapi_GetAgents_result result;
        result.return_value = __intf->GetAgents(result.agentInfoList, map);
        ret = proto->writeMessageBegin("global.ap.apapi", "GetAgents", ::bgcc::REPLY, seqid);
        if (ret < 0) { return ret;}
        ret = result.write(proto);
        if (ret < 0) { return ret; }

        ret = proto->writeMessageEnd();
        return ret;
    }

}