Location: PHPKode > projects > Monyet > classes/netmapagent.php
<?php
Class NetMapAgent Extends EntityBase implements Observer{

	private $agent;
	private $x;
	private $y;

	public function __construct(){
		//PHYSIC TABLE DEFINITION for NetMapAgent
		//-----------------------------------------------------
		$tablename = 'mapnetwork';
		
		$field_agent = 'agent_id';
		$field_x = 'x';
		$field_y = 'y';
		//-----------------------------------------------------
		
		$rawfields = array('agent'=>$field_agent,'x'=>$field_x,'y'=>$field_y);
		$agent = new Agent();	 
		$attributes = array($agent->getAbsField('description'),$field_x,$field_y);
		$condition = $agent->getPrimaryKey().' = '.$tablename.'.'.$field_agent;

		parent::__construct(array($tablename,$agent->getPrimaryTable()),$field_agent,$attributes,$rawfields,$condition);
	}

	//not yet tested
	//should be listen to Agent
	public function notifyRemove($obj,$id){
		if($obj instanceOf Group){
			$this->removeWith($this->getField('group'),$id);
		}
	}

	public function selectRemaining(){
		$agent = new Agent();
		$field_agent_id = $agent->getField('id');
		$field_agent_hostname = $agent->getField('description');

		$sql = 'SELECT '.$field_agent_id.','.$field_agent_hostname.' FROM '.$agent->getPrimaryTable().' WHERE '.
				  $field_agent_id.' NOT IN (SELECT '.$this->getField('agent').' FROM '.$this->getPrimaryTable().')';
		$temp = $this->dba->query($sql);
		$result = array();
		for($i=0;$i<sizeof($temp);$i++){
			$result[$temp[$i]->$field_agent_id] = $temp[$i]->$field_agent_hostname;
		}
		return $result;
	}
	
	//this is only wrapper to provide single object
	//just copy paste for all children
	public function selectByID($id){
		$tempobj = parent::selectByID($id);
		if($tempobj){
			foreach($this->rawfields as $key => $value){
				$this->$key = $tempobj->$value;
			}
		}
	}

	public function getX(){
		return $this->x;
	}

	public function getY(){
		return $this->y;
	}

	public function __destruct(){
		parent::__destruct();	
	}
}

?>
Return current item: Monyet