1 /* 2 * Entreri, an entity-component framework in Java 3 * 4 * Copyright (c) 2013, Michael Ludwig 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without modification, 8 * are permitted provided that the following conditions are met: 9 * 10 * Redistributions of source code must retain the above copyright notice, 11 * this list of conditions and the following disclaimer. 12 * Redistributions in binary form must reproduce the above copyright notice, 13 * this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 package com.lhkbob.entreri; 28 29 /** 30 * Owner is a listener and tag interface so that {@link Ownable} implementations can 31 * report ownership changes to their owners. This is used by both Components and Entities 32 * to track which objects they own and disown them when they are removed from the 33 * EntitySystem. 34 * 35 * @author Michael Ludwig 36 */ 37 public interface Owner { 38 /** 39 * Notify this Owner that it is now <var>obj</var>'s owner. This must only be called 40 * by {@link Ownable} implementations in response to calls to {@link 41 * Ownable#setOwner(Owner)}. 42 * <p/> 43 * This method returns the true Owner instance, to allow for flyweight objects to act 44 * as Owners. In this case, they will return the canonical owner for the datum they 45 * represent. In regular cases, this will return itself after recording ownership. 46 * 47 * @param obj The newly owned object 48 * 49 * @return The actual owner in the event that the owner was a flyweight object 50 */ 51 public Owner notifyOwnershipGranted(Ownable obj); 52 53 /** 54 * <p/> 55 * Notify this Owner that it is no longer <var>obj</var>'s owner. This must only be 56 * called by {@link Ownable} implementations in response to calls to {@link 57 * Ownable#setOwner(Owner)}. 58 * <p/> 59 * Ownership is revoked when the Ownable is assigned a new owner, or the null owner 60 * but was previously owned by this instance. 61 * 62 * @param obj The disowned object 63 */ 64 public void notifyOwnershipRevoked(Ownable obj); 65 }