| net :: dbus :: Æ©Å丮¾ó :: exportingObjects. NET :: DBUS :: Tutorial :: exportingObjects´Â DBUS ¼ºñ½º¸¦ Á¦°øÇÏ´Â ÀÚ½À¼°¡ Æ÷ÇÔ µÈ Perl ¸ðµâÀÔ´Ï´Ù. |
Áö±Ý ´Ù¿î·Îµå |
net :: dbus :: Æ©Å丮¾ó :: exportingObjects. ¼øÀ§ ¹× ¿ä¾à
- ƯÇã:
- Perl Artistic License
- °Ô½ÃÀÚ À̸§:
- Daniel Berrange
- °Ô½ÃÀÚ À¥»çÀÌÆ®:
- http://search.cpan.org/~danberr/Config-Record-1.1.2/lib/Config/Record.pod
net :: dbus :: Æ©Å丮¾ó :: exportingObjects. ű×
net :: dbus :: Æ©Å丮¾ó :: exportingObjects. ¼³¸í
net :: DBUS :: Tutorial :: exportingObjects´Â DBUS ¼ºñ½º¸¦ Á¦°øÇÏ´Â Æ©Å丮¾óÀ» Æ÷ÇÔÇÏ´Â Perl ¸ðµâÀÔ´Ï´Ù. net :: DBUS :: Tutorial :: exportingObjects´Â DBUS ¼ºñ½º¸¦ Á¦°øÇÏ´Â Æ©Å丮¾óÀ» Æ÷ÇÔÇÏ´Â Perl ¸ðµâÀÔ´Ï´Ù.ÀÌ ¹®¼´Â Perl Net :: DBU ÀÀ¿ë ÇÁ·Î±×·¥ ¹ÙÀεùÀ» »ç¿ëÇÏ¿© DBUS ¼ºñ½º¸¦ Á¦°øÇÏ´Â µ¥¿¡ ´ëÇÑ ÀÚ½À¼¸¦ Á¦°øÇÕ´Ï´Ù. ÀÌ ¹®¼ ÀÇÀÌ ¹®¼¿¡¼´Â À½¾Ç Æ®·¢ Ç÷¹À̾ Á¦°øÇÏ´Â °£´ÜÇÑ DBUS ¼ºñ½º ÀÎ Music :: Player ¹èÆ÷ÆÇÀÇ Äڵ带 ±â¹ÝÀ¸·ÎÇÕ´Ï´Ù. °´Ã¼¸¦ ¸¸µé ¶§ °´Ã¼¸¦ ¸¸µé ¶§ ù ¹ø° ´Ü°è´Â ±×¹°À» »ó¼ÓÇÏ´Â »õ ÆÐÅ°Áö¸¦ ¸¸µå´Â °ÍÀÔ´Ï´Ù. :: DBUS :: Object. À½¾Ç :: Player :: Manager °³Ã¼´Â ´Ù¾çÇÑ Æ®·¢ À¯Çü¿¡ ´ëÇÑ À½¾Ç Ç÷¹ÀÌ¾î ¹é¿£µå ¸ðÀ½À» °ü¸®ÇÏ´Â API¸¦ Á¦°øÇÕ´Ï´Ù. ½ÃÀÛÇÏ·Á¸é ÆÐÅ°Áö¿Í »ý¼ºÀÚÀÇ ÇØ°ñÀ» ¸¸µé ¼ö ÀÖ½À´Ï´Ù. ½´ÆÛ Å¸ÀÔÀÇ »ý¼ºÀÚ, net :: dbus :: °´Ã¼´Â ¸Å°³ º¯¼ö¿¡ ÁÖ¾îÁú °ÍÀ¸·Î ¿¹»óÇÕ´Ï´Ù. °´Ã¼¸¦ ¼ÒÀ¯ÇÏ´Â Net :: DBUS :: Service ¹× °´Ã¼°¡ ³»º¸³»¾î¾ßÇÏ´Â °æ·Î. Manager Ŭ·¡½º´Â ½Ì±Û Åæ °´Ã¼·Î ÀǵµµÇ¹Ç·Î »ý¼ºÀÚ ³»¿¡¼ °æ·Î¸¦ °ÈÇÒ ¼ö ÀÖ½À´Ï´Ù. Package Music :: Player :: Manager; ±âº» QW (net :: dbus)¸¦ »ç¿ëÇϽʽÿÀ. »õ {³» $ class = shift; MY $ SERVICE = SHIFT; ³» $ self = $ class-> super :: new ($ service, "/ music / player / manager"); $ self, $ class¸¦ ÃູÇϽʽÿÀ; $ self¸¦ µ¹·ÁÁÝ´Ï´Ù. } 1; ÀÌÁ¦´Â ¾ð±ÞÇßµíÀÌ, °ü¸®ÀÚ°¡ ´Ù¸¥ Ç÷¹ÀÌ¾î ¹é¿£µåÀÇ ¼ö¸¦ ó¸®ÇÕ´Ï´Ù. µû¶ó¼ ¿ì¸®´Â »õ·Î¿î ¹é¿£µå¸¦ µî·ÏÇÏ°í ƯÁ¤ ÆÄÀÏ À¯ÇüÀ» Àç»ýÇÒ ¼öÀÖ´Â ¹é¿£µå¸¦ Äõ¸®ÇÏ´Â ¹æ¹ýÀ» Á¦°øÇؾßÇÕ´Ï´Ù. À§ÀÇ Äڵ带 ¼öÁ¤ÇÏ¸é »ý¼ºÀÚ¿¡ Çؽà Å×À̺íÀ» Ãß°¡ÇÏ¿© ¹é¿£µå¸¦ ÀúÀåÇÕ´Ï´Ù. sub new {my $ class = shift; MY $ SERVICE = SHIFT; ³» $ self = $ class-> super :: new ($ service, "/ music / player / manager"); $ self-> {backends} = {}; $ self, $ class¸¦ ÃູÇϽʽÿÀ; $ self¸¦ µ¹·ÁÁÝ´Ï´Ù. } ¹× ÀÌÁ¦ »õ ¹é¿£µå¸¦ µî·ÏÇÏ´Â ¹æ¹ý. ÀÌ·¸°ÔÇϸé Perl ¸ðµâ À̸§ÀÌ ÇÊ¿äÇÏ¸ç ¹é¿£µå¸¦ ÀνºÅϽºÈÇÏ´Â µ¥ »ç¿ëµË´Ï´Ù. ¹é¿£µå´Â ¶ÇÇÑ DBUS °´Ã¼°¡ µÉ °ÍÀ̹ǷΠ¹é¿£µå¸¦ µî·Ï ÇÒ °æ·Î¿Í ÇÔ²² ÷ºÎ µÈ ¼ºñ½º¿¡ ´ëÇÑ ÂüÁ¶¸¦ ÂüÁ¶ÇؾßÇÕ´Ï´Ù. ¿ì¸®´Â Get_Service ¸Þ¼µå¸¦ »ç¿ëÇÏ¿© ¼ºñ½º¿¡ ´ëÇÑ ÂüÁ¶¸¦ ´Ù½Ã ÀÐÀ» ¼ö ÀÖ½À´Ï´Ù. Manager°¡ÀÌ µ¿ÀÏÇÑ ¼ºñ½º¿¡ ¿¬°áµÇ¾î ÀÖ°í µ¿ÀÏÇÑ ¼ºñ½º¿¡ Ç÷¹ÀÌ¾î ¹é¿£µå¸¦ ¿¬°áÇÕ´Ï´Ù. ù ¹ø° ¸Å°³ º¯¼ö´Â °´Ã¼ ÂüÁ¶ ($ self)ÀÌ°í ³ª¸ÓÁö´Â ¸Þ¼Òµå È£Ãâ¿¡ Á¦°øµÈ ¸Å°³ º¯¼öÀÔ´Ï´Ù. µû¶ó¼ DBUS¿¡ ¸Þ¼Òµå ±¸ÇöÀ» ÀÛ¼ºÇϸé Á¤»óÀûÀÎ °´Ã¼ ÁöÇâ PERL (CF PerlToot)°ú´Âº°·Î ´Ù¸¨´Ï´Ù. sub register_backend {My $ self = shift; ³» $ name = shift; ³» $ module = shift; eval "$ ¸ðµâ »ç¿ë"; if ($ @) {die "´Â ¹é¿£µå $ ¸ðµâÀ»·Îµå ÇÒ ¼ö ¾ø½À´Ï´Ù : $ @"; } $ self-> {backends} = $ module-> new ($ self-> get_service, "/ music / player / backend / $ name"); } DIE ¸Þ¼µå°¡ Æ®¸®°ÅµÇ¸é ¾î¶»°ÔµÇ´ÂÁö ±Ã±ÝÇØ ÇÒ ¼ö ÀÖ½À´Ï´Ù. ÀÌ·¯ÇÑ ½Ã³ª¸®¿À¿¡¼´Â ¼ºñ½º ÇÁ·Î¼¼½º¸¦ Á¾·áÇÏ´Â ´ë½Å ¿À·ù°¡ ÁöÁ¤µÇ¾î ¿ø°Ý È£ÃâÀÚ¿¡°Ô ´Ù½Ã ÀüÆĵ˴ϴÙ. Ç÷¹ÀÌ¾î ¹é¿£µå´Â Áö¿øµÇ´Â À½¾Ç Æ®·¢ À¯ÇüÀÇ ¹è¿ ÂüÁ¶¸¦ ¹ÝȯÇÏ´Â get_track_types ¸Þ¼Òµå¸¦ Á¦°øÇÕ´Ï´Ù. ¿ì¸®´ÂÀÌ ¹æ¹ýÀ» »ç¿ëÇÏ¿© ƯÁ¤ Æ®·¢ À¯Çü¿¡ ´ëÇÑ ¹é¿£µå¸¦ ½±°Ô °Ë»ö ÇÒ ¼ö ÀÖµµ·Ï API¸¦ Á¦°ø ÇÒ ¼ö ÀÖ½À´Ï´Ù. ÀÌ ¸Þ¼µå´Â ¹é¿£µå °´Ã¼°¡ Sub find_backend {My $ self = shift;; ³» $ Extension = Shift; ³» $ name (Å° % {$ self-> {backends}}) {my $ backend = $ self-> {backend} -> {$ name}; Foreach My $ Type (@ {$ Backend-> get_track_types}) {if ($ type eq $ È®ÀåÀÚ) {$ $ backend-> get_object_path¸¦ ¹ÝȯÇϽʽÿÀ; }}} DIE "$ Extension À¯Çü¿¡ ´ëÇÑ ¹é¿£µå ¾øÀ½"; }ÀÌ ¸Þ¼µå°¡ À½¾Ç Æ®·¢À» Àç»ýÇÏ´Â µ¥ ¾î¶»°Ô »ç¿ëµÇ´ÂÁö °í·ÁÇغ¸½Ê½Ã¿À. ¾ÆÁ÷ ¼öÇàÇÏÁö ¾Ê¾Ò´Ù¸é net :: DBUS :: Tutorial :: UskingObjects¿¡¼ ¸Þ¸ð¸®¸¦ »õ·Î °íĨ´Ï´Ù. ÀÌÁ¦ ¿ì¸®´Â Àç»ýÇÏ°íÀÚÇÏ´Â MP3 ÆÄÀÏÀ» °¡Áö°í ÀÖÀ¸¹Ç·Î ¹é¿£µåÀÇ °æ·Î¸¦ °Ë»ö ÇÑ ´ÙÀ½ °´Ã¼¸¦ °Ë»öÇÏ°í Æ®·¢À» Àç»ýÇÕ´Ï´Ù. ... À½¾Ç Ç÷¹ÀÌ¾î ¼ºñ½º¸¦ ¹ÞÀ¸½Ê½Ã¿À ... # MP3 ÆÄÀÏ ¿ë Ç÷¹ÀÌ¾î °æ·Î My $ Path = $ Service-> Find_Backend ( "MP3"); # $ Path´Â '/ Music / Player / Backend / MPG123'À» Æ÷ÇÔÇÏ°í ÀÖÀ¸¸ç ¹é¿£µå °´Ã¼¸¦ ¾òÀ» ¼ö ÀÖ½À´Ï´Ù My $ Backend = $ Service-> get_object ($ Path); # ±×¸®°í ¸¶Áö¸·À¸·Î Æ®·¢ $ ¹é¿£µå -> Àç»ý ( "/ vol / music / beck / guero / 09-scarecrow.mp3")À» Àç»ýÇÕ´Ï´Ù. ¿ä±¸ »çÇ× : ¡¤ Perl.
net :: dbus :: Æ©Å丮¾ó :: exportingObjects. °ü·Ã ¼ÒÇÁÆ®¿þ¾î