{"id":2031,"date":"2011-02-12T22:54:44","date_gmt":"2011-02-12T13:54:44","guid":{"rendered":"http:\/\/www.moonmile.net\/blog\/archives\/2031"},"modified":"2011-02-12T22:55:16","modified_gmt":"2011-02-12T13:55:16","slug":"%e3%83%ab%e3%82%a4%e3%82%b9%e3%81%af%e3%82%a2%e3%83%aa%e3%82%b9%e3%81%ab%e3%83%97%e3%83%a9%e3%83%80%e3%82%92%e9%9b%bb%e9%80%81%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"http:\/\/www.moonmile.net\/blog\/archives\/2031","title":{"rendered":"\u30eb\u30a4\u30b9\u306f\u30a2\u30ea\u30b9\u306b\u30d7\u30e9\u30c0\u3092\u96fb\u9001\u3059\u308b"},"content":{"rendered":"<p>\n\u96fb\u8a71\u6a5f\u80fd(Telephone)\u3068\u30b7\u30ea\u30a2\u30e9\u30a4\u30ba\u6a5f\u80fd(ISerialize)\u3092\u540c\u6642\u306b\u5229\u7528\u3059\u308b\u3068\u3001<b>\u96fb\u9001<\/b>\u304c\u3067\u304d\u307e\u3059(\u7b11)\u3002\u300c\u7269\u7406\u8ee2\u9001\u300d\u3063\u3066\u3044\u3046\u8a00\u8449\u3092\u4f7f\u3063\u3066\u3044\u308b\u306e\u306f\u3001\u6700\u8fd1 SF \u3092\u8aad\u3093\u3067\u3044\u306a\u3044\u306a\u3041\u3068\u601d\u3044\u3064\u3064\u672c\u5c4b\u3055\u3093\u306b\u884c\u3063\u305f\u3089\u30df\u30b9\u30c6\u30ea\u30fc\u3057\u304b\u4e26\u3093\u3067\u3044\u306a\u3044\u3058\u3083\u3093\u30c3!!! \u65e9\u5dddSF\u6587\u5eab\u306f\u4f55\u51e6\u3078\u3068\u63a2\u3057\u3066\u3044\u305f\u3089\u3001\u30a2\u30fc\u30b5\u30fc\u30fbC\u30fb\u30af\u30e9\u30fc\u30af\u306e\u30d9\u30b9\u30c8\u96c6\u304c\u58f2\u3063\u3066\u3044\u305f\u306e\u3067\u3001\u4ed5\u65b9\u304c\u306a\u304f\u300c\u3048\u30c3!!! 1000\u5186\u306a\u3093\u3067\u3059\u304b??? \u6587\u5eab\u306a\u306e\u306b\u3001\u3053\u3093\u306a\u306b\u9ad8\u3044\u3093\u3058\u3083\u8b1b\u8ac7\u793e\u5b66\u8853\u6587\u5eab\u3084\u7b51\u6469\u6587\u5eab\u3068\u540c\u3058\u3058\u3083\u306a\u3044\u3067\u3059\u304b\u30c3!!!\u300d\u3063\u3066\u306a\u611f\u3058\u3067\u4ed5\u65b9\u306a\u304f\u8cb7\u3063\u3066\u304d\u3066\u3001100\u9801\u307b\u3069\u4e00\u6c17\u8aad\u307f\u3001\u3057\u305f\u304b\u3089\u3067\u3059\u3002\u306a\u308b\u307b\u3069\u3001SF \u3061\u3063\u304f\u306a\u672c\u3092\u8aad\u3082\u3046\u3068\u3059\u308b\u3068\u3001\u30e9\u30ce\u30d9\u306e\u307b\u3046\u304c\u305d\u308c\u3089\u3057\u3044(\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3068\u304b\u30ec\u30fc\u30eb\u30ac\u30f3\u3068\u304b\u767d\u4e95\u9ed2\u5b50\u3068\u304b&#8230;)\u306a\u3093\u3060\u306a\u3041\u3001\u3068\u601d\u3063\u305f\u308a\u601d\u308f\u306a\u304b\u3063\u305f\u308a\u3002\n<\/p>\n<p>\n\u305d\u3093\u306a\u8a33\u3067\u3001<b>\u96fb\u9001<\/b>\u3057\u3066\u3044\u308b\u306e\u304c\u6b21\u306e\u30b3\u30fc\u30c9\u3067\u3059\u3002\n<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\n\/\/ for \u30eb\u30a4\u30b9\u306f\u30a2\u30ea\u30b9\u306b\u30d7\u30e9\u30c0\u3092\u96fb\u9001\u3059\u308b\n#include &lt;string.h&gt;\n#include &lt;iostream&gt;\nusing namespace std;\n\nclass Person ;\n\nclass Telephone {\nprotected:\n\tTelephone *_telephone;\n\tPerson *_person ;\n\tvoid (Person::*_onPhone)(const void *, int);\n\npublic:\n\t\/\/ \u81ea\u5206\u306e onPhone \u3092\u767b\u9332\n\tvoid setMyPhone(Person *person, void (Person::*onPhone)(const void *, int)) {\n\t\t_person = person ;\n\t\t_onPhone = onPhone;\n\t} \n\t\/\/ \u76f8\u624b\u5148\u3092\u767b\u9332\n\tvoid setPhone( Telephone *telephone ) {\n\t\tthis-&gt;_telephone = telephone ;\n\t}\n\t\/\/ \u30c7\u30fc\u30bf\u3092\u9001\u4fe1\n\tvirtual void sendData( const void *data, int size ) {\n\t\tif ( _telephone != NULL ) {\n\t\t\t_telephone-&gt;onPhone(data,size);\n\t\t}\n\t}\n\t\/\/ \u30c7\u30fc\u30bf\u3092\u53d7\u4fe1\u3059\u308b\u95a2\u6570\n\tvirtual void onPhone( const void *data, int size ) {\n\t\tif ( _onPhone != NULL ) {\n\t\t\t(_person-&gt;*_onPhone)( data, size );\n\t\t}\n\t} \n};\nclass ISerialize {\n\t\/\/ \u30b7\u30ea\u30a2\u30e9\u30a4\u30ba\u5316\n\tvoid *Serialize();\n\t\/\/ \u30c7\u30fc\u30bf\u304b\u3089\u5fa9\u5143\n\tstatic void Serialize( void * );\n};\n\nclass Bag : public ISerialize \n{\npublic:\n\t\/\/ \u5229\u7528\u30d5\u30e9\u30b0\n\tbool used ;\n\t\/\/ \u6301\u3061\u4e3b\u306e\u540d\u524d\n\tchar ownerName&#x5B;30];\n\t\/\/ \u30d6\u30e9\u30f3\u30c9\u540d\n\tchar brandName&#x5B;30];\npublic:\n\t\/\/ \u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\n\tBag() : used(false) {\n\t\townerName&#x5B;0] = &#039;&amp;#92;&amp;#48;&#039;;\n\t\tbrandName&#x5B;0] = &#039;&amp;#92;&amp;#48;&#039;;\n\t}\n\t\/\/ \u30a2\u30af\u30bb\u30c3\u30b5\n\tbool getUsed() { return used; }\n\tstring getOwnerName() { return ownerName; }\n\tvoid setOwnerName( string name ) {\n\t\tif ( ownerName&#x5B;0] == &#039;&amp;#92;&amp;#48;&#039; ) {\n\t\t\tstrcpy( ownerName, (const char*)name.c_str() );\n\t\t}\n\t\t\n\t}\n\tstring getBrandName() { return brandName; }\n\tvoid setBrandName( string name ) {\n\t\tif ( brandName&#x5B;0] == &#039;&amp;#92;&amp;#48;&#039; ) {\n\t\t\tstrcpy( brandName, (const char*)name.c_str() );\n\t\t}\n\t}\n\t\/\/ \u5229\u7528\u3059\u308b\n\tvirtual void Use() {\n\t\tthis-&gt;used = true;\n\t}\n\t\/\/ \u30b7\u30ea\u30a2\u30e9\u30a4\u30ba\n\tvirtual void *Serialize() {\n\t\tint size = sizeof(Bag);\n\t\tvoid *data = new char&#x5B;size];\n\t\tmemcpy( data,this, size );\n\t\treturn data;\n\t}\n\t\/\/ \u9006\u30b7\u30ea\u30a2\u30e9\u30a4\u30ba\n\tstatic Bag *Serialize(void *data) {\n\t\tBag *bag = (Bag*)data;\n\t\treturn bag;\n\t}\n};\nclass Prada : public Bag \n{\npublic:\n\tPrada() : Bag() {\n\t\tstrcpy( brandName, &amp;quot;Prada&amp;quot; );\n\t}\n};\nclass Tiffany : public Bag \n{\npublic:\n\tTiffany() : Bag() {\n\t\tstrcpy( brandName, &amp;quot;Tiffany&amp;quot; );\n\t}\n};\n\nclass Person\n{\npublic:\n\tchar _name&#x5B;30];\n\tTelephone _phone;\npublic:\n\t\/\/ \u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\n\tPerson( const char *name ) {\n\t\tstrcpy( _name, name );\n\t\t\/\/ \u81ea\u5206\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u3092\u767b\u9332\n\t\t_phone.setMyPhone( this, &amp;Person::onPhone );\n\t}\n\t\/\/ \u76f8\u624b\u306b\u96fb\u8a71\u3092\u639b\u3051\u308b\n\tvoid setPhone( Person *person ) {\n\t\t_phone.setPhone(person-&gt;getPhone());\n\t}\n\t\/\/ \u96fb\u8a71\u3092\u53d7\u3051\u53d6\u308b\u30a2\u30af\u30bb\u30c3\u30b5\n\tTelephone *getPhone() {\n\t\treturn &amp;(this-&gt;_phone);\n\t}\n\t\/\/ \u30c7\u30fc\u30bf\u53d7\u4fe1\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570\n\tvirtual void onPhone( const void *data, int size ) {\n\t\tcout &lt;&lt; &amp;quot;to &amp;quot; &lt;&lt; _name &lt;&lt; &amp;quot;: &amp;quot; &lt;&lt; (char*)data &lt;&lt; endl;\n\t}\n\t\/\/ \u30c7\u30fc\u30bf\u9001\u4fe1\u306e\u95a2\u6570\n\tvirtual void sendPhone( const void *data, int size ) {\n\t\tif ( size == 0 ) {\n\t\t\tcout &lt;&lt; &amp;quot;from &amp;quot; &lt;&lt; _name &lt;&lt; &amp;quot;: &amp;quot; &lt;&lt; (char*)data &lt;&lt; endl;\n\t\t} else {\n\t\t\tcout &lt;&lt; &amp;quot;from &amp;quot; &lt;&lt; _name &lt;&lt; &amp;quot;: send bag.&amp;quot; &lt;&lt; endl;\n\t\t}\n\t\t_phone.sendData( data, size );\n\t}\n};\n\nclass Alice : public Person \n{\nprivate:\n\tBag *_bag;\npublic:\n\tAlice() : Person(&amp;quot;alice&amp;quot;), _bag(NULL) {\n\t}\n\t\/\/ \u30c7\u30fc\u30bf\u53d7\u4fe1\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570\n\tvirtual void onPhone( const void *data, int size ) \n\t{\n\t\tif ( size == 0 ) \n\t\t{\n\t\t\tcout &lt;&lt; _name &lt;&lt; &amp;quot;:&amp;quot; &lt;&lt; &amp;quot;this is no bag!!!&amp;quot; &lt;&lt; endl;\n\t\t} else {\n\t\t\tBag *bag = (Bag*)data;\n\t\t\tPrada *prada = dynamic_cast&lt;Prada*&gt;(bag);\n\t\t\tif ( prada == NULL ) {\n\t\t\t\tcout &lt;&lt; _name &lt;&lt; &amp;quot;:&amp;quot; &lt;&lt; &amp;quot;this is no Prada!!!&amp;quot; &lt;&lt; endl;\n\t\t\t} else {\n\t\t\t\tcout &lt;&lt; _name &lt;&lt; &amp;quot;:&amp;quot; &lt;&lt;\t&amp;quot;thank you Prada.&amp;quot; &lt;&lt; endl;\n\t\t\t\tthis-&gt;_bag = Bag::Serialize((void*)data );\n\t\t\t}\n\t\t}\n\t}\n\tstring getBrandName() {\n\t\treturn _bag-&gt;getBrandName();\n\t}\n\t\t\n};\n\nint main(void)\n{\n\tAlice alice;\n\tPerson lewis(&amp;quot;lewis&amp;quot;);\n\n\t\/\/ \u30a2\u30ea\u30b9\u306b\u96fb\u8a71\u3092\u639b\u3051\u308b\u3002\n\tlewis.setPhone( &amp;alice );\n\t\/\/ hello \u3068\u8a00\u3046\n\tlewis.sendPhone( &amp;quot;hello&amp;quot;, 0 );\n\t\/\/ \u30c6\u30a3\u30d5\u30a1\u30cb\u30fc\u3092\u8ee2\u9001\n\tBag *bag = new Tiffany();\n\tlewis.sendPhone( bag-&gt;Serialize(), sizeof(Tiffany));\n\tdelete bag;\n\t\/\/ \u30d7\u30e9\u30c0\u3092\u8ee2\u9001\n\tbag = new Prada();\n\tlewis.sendPhone( bag-&gt;Serialize(), sizeof(Prada));\n\tdelete bag;\n\t\/\/ \u30a2\u30ea\u30b9\u304c\u6301\u3063\u3066\u3044\u308b\u306e\u306f\u30d7\u30e9\u30c0\u306e\u9784\n\tcout &lt;&lt; &amp;quot;alice has &amp;quot; &lt;&lt; alice.getBrandName() &lt;&lt; endl;\n\treturn 0;\n}\n<\/pre>\n<p>\n\u9001\u3063\u3066\u304f\u308b\u30b5\u30a4\u30ba\u3092\u30c1\u30a7\u30c3\u30af\u305b\u305a\u306b Bag \u30af\u30e9\u30b9\u6c7a\u3081\u6253\u3061\u306a\u306e\u306f\u3001\u5225\u306b\u8003\u3048\u308b\u3068\u3057\u3066\u3001\u3053\u306e\u96fb\u9001\u65b9\u5f0f\u306f\u8ee2\u9001\u5143\u3067\u30b3\u30d4\u30fc\u3092\u4f5c\u3063\u3066\u304a\u3044\u3066\u3001\u8ee2\u9001\u5148\u3067\u305d\u306e\u30e1\u30e2\u30ea\u3092\u4f7f\u3046\u3063\u3066\u3044\u3046\u65b9\u5f0f\u3067\u3059\u306d\u3002\u52ff\u8ad6\u3001\u8ee2\u9001\u5148\u3067\u30b3\u30d4\u30fc\u3092\u4f5c\u3063\u3066\u3082\u3044\u3044\u308f\u3051\u3067\u3059\u304c\u3001\u61d0\u304b\u3057\u306e WM_COPYDATA \u306f\u3001\u3053\u306e\u65b9\u5f0f\u306a\u306e\u3067\u3053\u308c\u306b\u3057\u3066\u307f\u307e\u3057\u305f\u3002\u3068\u8a00\u3046\u306e\u306f\u5f8c\u4ed8\u3051\u3067\u3057\u3066\u3001\u96fb\u9001\u3068\u3044\u3046\u306e\u3060\u304b\u3089\u3001\n<\/p>\n<ol>\n<li>\u96fb\u9001\u5143\u3067\u3001\u4e00\u5ea6\u3001\u96fb\u5b50\u30ec\u30d9\u30eb\u306b\u5206\u89e3\u3057\u3066<\/li>\n<li>\u96fb\u9001\u3057\u3066\u3044\u308b\u9593\u306f\u3001\u5358\u306a\u308b\u30d3\u30c3\u30c8\u5217\u306b\u3057\u3066\u3001<\/li>\n<li>\u96fb\u9001\u5148\u3067\u3001\u306a\u3093\u3089\u304b\u306e\u5f62\u3067\u5143\u306b\u623b\u3059\u3002<\/li>\n<\/ol>\n<p>\n\u3068\u3044\u3046\u30b9\u30bf\u30fc\u30c8\u30ec\u30c3\u30af\u306a\u96fb\u9001\u65b9\u5f0f\u304c\u30a4\u30e1\u30fc\u30b8\u3067\u304d\u308b\u3082\u306e\u304c\u3044\u3044\u3067\u3059\u3088\u306d\u3002\u3053\u306e Telephone \u3060\u3068\u3001\u96fb\u8a71\u3068\u96fb\u8a71\u306e\u9593\u306e\u96fb\u9001\u7dda\u306e\u30a4\u30e1\u30fc\u30b8\u304c\u5165\u3063\u3066\u3044\u306a\u3044\u306e\u3067\u3001<b>\u5358\u306a\u308b\u30d3\u30c3\u30c8\u5217<\/b>\u3063\u3066\u306e\u304c\u60f3\u50cf\u3057\u3065\u3089\u3044\u306e\u3067\u3059\u3002\u3044\u308f\u3070\u3001\u3053\u306e\u9593\u306f SOAP \u3060\u3063\u305f\u308a XML \u30c7\u30fc\u30bf\u3060\u3063\u305f\u308a\u3059\u308b\u308f\u3051\u3067\u3001\u4e00\u756a\u7c21\u5358\u306a\u306e\u304c\u5143\u306e\u30c7\u30fc\u30bf\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3092\u7dad\u6301\u3057\u305f\u30d3\u30c3\u30c8\u5217(\u4eca\u56de\u306e\u65b9\u5f0f)\u3067\u3059\u306d\u3002\u30d3\u30c3\u30c8\u5217\u306e\u5834\u5408\u3001\u4e21\u65b9\u306e\u7aef\u672b\u304c\u540c\u3058 CPU\/OS \u3067\u3042\u308b\u5fc5\u8981\u304c\u3042\u308b\u306e\u3067(\u30a8\u30f3\u30c7\u30a3\u30a2\u30f3\u3068\u304b\u30d1\u30c7\u30a3\u30f3\u30b0\u3068\u304b)\u3001\u3053\u306e\u8ee2\u9001\u3057\u3066\u3044\u308b\u9593\u306f\u3001\u5225\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u304c\u3088\u304b\u3063\u305f\u308a\u3057\u307e\u3059\u3002\u3068\u3044\u3046\u304b\u305d\u3046\u3044\u3046\u73fe\u5b9f\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\n<\/p>\n<p>\n\u3093\uff5e\u3001\u3053\u308c\u304f\u3089\u3044\u306b\u306a\u308b\u3068\u30af\u30e9\u30b9\u56f3\u3092\u793a\u3055\u306a\u3044\u3068\u5206\u304b\u308a\u3065\u3089\u3044\u3067\u3059\u306d\u3002\u3053\u306e\u3042\u305f\u308a\u306f\u5f8c\u7a0b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u96fb\u8a71\u6a5f\u80fd(Telephone)\u3068\u30b7\u30ea\u30a2\u30e9\u30a4\u30ba\u6a5f\u80fd(ISerialize)\u3092\u540c\u6642\u306b\u5229\u7528\u3059\u308b\u3068\u3001\u96fb\u9001\u304c\u3067\u304d\u307e\u3059(\u7b11)\u3002\u300c\u7269\u7406\u8ee2\u9001\u300d\u3063\u3066\u3044\u3046\u8a00\u8449\u3092\u4f7f\u3063\u3066\u3044\u308b\u306e\u306f\u3001\u6700\u8fd1 SF \u3092\u8aad\u3093\u3067\u3044\u306a\u3044\u306a\u3041\u3068\u601d\u3044\u3064\u3064\u672c\u5c4b\u3055\u3093\u306b\u884c\u3063\u305f\u3089\u30df\u30b9\u30c6 &hellip; <a href=\"http:\/\/www.moonmile.net\/blog\/archives\/2031\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[22],"tags":[],"class_list":["post-2031","post","type-post","status-publish","format-standard","hentry","category-c"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/2031","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/comments?post=2031"}],"version-history":[{"count":1,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/2031\/revisions"}],"predecessor-version":[{"id":2032,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/2031\/revisions\/2032"}],"wp:attachment":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/media?parent=2031"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/categories?post=2031"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/tags?post=2031"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}