generic parent object handling
[potlatch2.git] / net / systemeD / halcyon / connection / Relation.as
1 package net.systemeD.halcyon.connection {
2
3     public class Relation extends Entity {
4         private var members:Array;
5                 public static var entity_type:String = 'relation';
6
7         public function Relation(id:Number, version:uint, tags:Object, members:Array) {
8             super(id, version, tags);
9             this.members = members;
10                         for each (var member:RelationMember in members) { member.entity.addParent(this); }
11         }
12
13         public function get length():uint {
14             return members.length;
15         }
16
17         public function getMember(index:uint):RelationMember {
18             return members[index];
19         }
20
21         public function setMember(index:uint, member:RelationMember):void {
22                         member.entity.addParent(this);
23                         members.splice(index, 1, member);
24         }
25
26         public function insertMember(index:uint, member:RelationMember):void {
27                         member.entity.addParent(this);
28             members.splice(index, 0, member);
29         }
30
31         public function appendMember(member:RelationMember):uint {
32                         member.entity.addParent(this);
33             members.push(member);
34             return members.length;
35         }
36
37         public function removeMember(index:uint):void {
38             var removed:Array=members.splice(index, 1);
39                         removed[0].entity.removeParent(this);
40         }
41
42                 public override function getType():String {
43                         return 'relation';
44                 }
45     }
46
47 }