Reply to Re: Listing objects

Your name:

Reply:


Posted by Lόpher Cypher on 12/30/05 17:05

Peter Fox wrote:
> Following on from LΓΌpher Cypher's message. . .
>> Hi,
>>
>> Suppose we have a hierarchical class structure that looks something like
>> this:
> Sorry, I lost the plot half way through.
>
> Your objects can be
> 1 - nesting : object has a 'what are my children' and 'who is my
> parent' functionality.
>
> 2 - pointing : eg object has a 'these are my siblings' or
> 'previous/next' functionality
>
> 3 - dictionary entries : object in some container is discoverable by name
>

It is more of a [1] and [3] :)
[1] for I do have a tree-like structure of objects. I have $parent (for
all objects) and $owner (for objects that are of subclasses of some
class) properties so, I can go bottom-up. I also do have children array
for objects that have owner so, I can go top-down.
[3] for I am trying to have a global associative array that has unqiue
object names as keys and object references as values.

> Variations and combinations of course apply. BUT every object exists in
> some context. I /think/ you might be trying to get A's to point-to/own
> B's where more than one A could be the parent of a B. Eg
> "Sally is daughter of Jean"
> "Geoffrey is son of Teddy"
> "Sally is daughter of Teddy" // Only one Sally! J+T are married.
>
> In this case[1] create an array of children and point to elements in
> that array from your parent objects.
>
> eg $child['Sally'] = new ChildObj(.....);
> then $Jean->AddChild('Sally') // just a key name or index
> or $Jean->AddChild($child['Sally']) // inside the routine do $myKids[]
> = & $NewChild
> where $NewChild is the function argument.
>
> [1] If in this example children can be parents then you should be
> looking at a single universal 'person' class with the necessary links.
>

I do have a universal class :)
Say,

class Object
var $name;
var $owner;
var $children[];


Now,

class A extends Object
class B extends Object

A's can be owned by A's and/or B's, B's can have many A's and/or B's
B's can be owned by A's and/or B's and can have many A's and/or B's as well.

One of the things I am trying to do is to have global references to all
Objects:

global $objects;
$objects = array();

function Object() {
global $objects;
... assign name ...
$objects[$this->name] = &$this;
}

However, if a property of some Object changes, $objects[$object_name]
still has the "old" object. I assume $objects[$object_name] does not
reference the object then, rather has a copy of it. So far I was unable
to solve this.. By the way, this will work:

$obj = new Object();
$objects[$obj->name] = &$obj;

if it is executed outside any function and any class..


luph

[Back to original message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация