Maple für Professional
Maple für Akademiker
Maple für Studenten
Maple Personal Edition
Maple Player
Maple Player für iPad
MapleSim für Professional
MapleSim für Akademiker
Maple T.A. - Testen & beurteilen
Maple T.A. MAA Placement Test Suite
Möbius - Online-Courseware
Machine Design / Industrial Automation
Luft- und Raumfahrt
Fahrzeugtechnik
Robotics
Energiebranche
System Simulation and Analysis
Model development for HIL
Anlagenmodelle für den Regelungsentwurf
Robotics/Motion Control/Mechatronics
Other Application Areas
Mathematikausbildung
Technik
Allgemein- und berufsbildende Schulen
Testen und beurteilen
Studierende
Finanzmodelle
Betriebsforschung
Hochleistungsrechnen
Physik
Live-Webinare
Aufgezeichnete Webinare
Geplante Veranstaltungen
MaplePrimes
Maplesoft-Blog
Maplesoft-Mitgliedschaft
Maple Ambassador Program
MapleCloud
Technische Whitepapers
E-Mail Newsletters
Maple-Bücher
Math Matters
Anwendungs-Center
MapleSim Modell-Galerie
Anwenderberichte
Exploring Engineering Fundamentals
Lehrkonzepte mit Maple
Maplesoft Welcome-Center
Resource-Center für Lehrer
Help-Center für Studierende
ModuleCopy - Object を使用したオブジェクトのコピー方法を指定
使い方
module() option object; export ModuleCopy, ...; ... end module;
説明
object でメソッド ModuleCopy が定義されている場合、Object のコールによって同じクラスの新しいオブジェクトが作成されるときに、そのメソッドが呼び出されます。
ModuleCopy ルーチンを実装するのは、主に次の理由によります。
新しく作成されたオブジェクトのデータメンバーを (Object ルーチンに渡された引数に基づいて) プロトタイプオブジェクトのデータメンバーとは異なる値で初期化するため。
データメンバーのディープコピーを実行するため (たとえば、両方のオブジェクトが同じ rtable を参照するのではなく、rtable メンバーのコピーを作成するなど)
ModuleCopy 関数は object (つまり、option object で宣言されている) であるモジュールに対してのみ有用です。
ModuleCopy ルーチンの使い方は次のとおりです。
ModuleCopy::static := proc( new::Object, proto::Object, ... )
new は、初期化されている新規作成オブジェクトです。proto は、Object へのコールに渡されるプロトタイプオブジェクトです。残りの引数は Object ルーチンに渡されるオプションの引数です。
Object を呼び出す ModuleApply ルーチンを実装すると、ModuleCopy が起動してプロトタイプオブジェクトがオブジェクトファクトリーに適用されます。
互換性
ModuleCopy コマンドは Maple 16 で導入されました。
Maple 16 における変更点についての詳細は、Maple 16 の新機能 を参照してください。
例
module Obj1() option object; local data := 0; export getData::static := proc( self::Obj1 ) self:-data; end; export ModuleCopy::static := proc( self::Obj1, proto::Obj1, d, $ ) if ( _npassed = 2 ) then self:-data := proto:-data; else self:-data := d; end; end; end:
getData( Obj1 );
newObj1 := Object( Obj1 );
getData( newObj1 );
newObj2 := Object( Obj1, 10 );
getData( newObj2 );
module Obj2() option object; local data := 0; export getData::static := proc( self::Obj2 ) self:-data; end; export ModuleApply::static := proc( ) Object( Obj2, _passed ); end; export ModuleCopy::static := proc( self::Obj2, proto::Obj2, d, $ ) if ( _npassed = 2 ) then self:-data := proto:-data; else self:-data := d; end; end; end:
newObj1 := Obj2( );
newObj2 := Obj2( 10 );
関連項目
モジュール、ModuleApply、Object、オブジェクトの作成、オブジェクトの概要、プロシージャ、rtable
Download Help Document