473,399 Members | 4,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

How to "kind of" make shared an object? :)

I have this classes tree

GameManager 1 object
Game Multiple objects
Map 1 object
Player Multiple objects
Squads Multiple objects
Units Multiple objects

Now each Squad or Units have to know about data on it's Map

Say I have Game1 and Game 2
Game2 have different map than Game1
any unit1_1 of branch Game1 need to know about Map1
any unit1_2 of branch Game2 need to know about Map2

How to accomplish that?

Should I pass to Unit1_1 the Game1 instance?

I whould like the Map1 shared to all Game1 children objects somehow..the
same with Map2 and Game2

Right now I keep passing the map arround each time I need it way down to a
unit that move or do stuffs

--
Cheers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------
Nov 20 '05 #1
5 1020
What I want to know is if it is possible to make some kind of xml tree
walking, so I can go up and access any ancestor of a node... i my case nore
is a reference to a class instance

--
Cheers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"Crirus" <Cr****@datagroup.ro> wrote in message
news:e5**************@TK2MSFTNGP09.phx.gbl...
I have this classes tree

GameManager 1 object
Game Multiple objects
Map 1 object
Player Multiple objects
Squads Multiple objects
Units Multiple objects

Now each Squad or Units have to know about data on it's Map

Say I have Game1 and Game 2
Game2 have different map than Game1
any unit1_1 of branch Game1 need to know about Map1
any unit1_2 of branch Game2 need to know about Map2

How to accomplish that?

Should I pass to Unit1_1 the Game1 instance?

I whould like the Map1 shared to all Game1 children objects somehow..the
same with Map2 and Game2

Right now I keep passing the map arround each time I need it way down to a
unit that move or do stuffs

--
Cheers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

Nov 20 '05 #2
On Wed, 14 Jan 2004 11:14:32 +0200, Crirus wrote:

GameManager 1 object
Game Multiple objects
Map 1 object
Player Multiple objects
Squads Multiple objects
Units Multiple objects


I don't know fully what you are designing, but to my mind, Player should
not be on the same level as Game but rather a sub level of game:

GameManager
Game
Map
Player
Squads
Units

Player, to me is an element of a Map. It seems like it would be a child of
map. A GameManager contains Games which contain maps which contain players
which have squads of units.

If this is the case, then a single unit can traverse up through it parents
to get the map info.

Just my thoughts.

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Nov 20 '05 #3
the players are indeed childs of game.. was a TAB missing there
Map is a separate class only with data of the terrain
Players join to game not to map in my design

How to traverse up such a graph?

--
Cheers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"Chris Dunaway" <dunawayc@_lunchmeat_sbcglobal.net> wrote in message
news:1f******************************@40tude.net.. .
On Wed, 14 Jan 2004 11:14:32 +0200, Crirus wrote:

GameManager 1 object
Game Multiple objects
Map 1 object
Player Multiple objects
Squads Multiple objects
Units Multiple objects

I don't know fully what you are designing, but to my mind, Player should
not be on the same level as Game but rather a sub level of game:

GameManager
Game
Map
Player
Squads
Units

Player, to me is an element of a Map. It seems like it would be a child

of map. A GameManager contains Games which contain maps which contain players which have squads of units.

If this is the case, then a single unit can traverse up through it parents
to get the map info.

Just my thoughts.

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.

Nov 20 '05 #4
On Thu, 15 Jan 2004 09:47:30 +0200, Crirus wrote:
the players are indeed childs of game.. was a TAB missing there
Map is a separate class only with data of the terrain
Players join to game not to map in my design

How to traverse up such a graph?


My only thought on that would be that each object would have a "parent"
property or perhaps a "ContainedBy" proprty that contains a reference to
the object that contains them. As each object is created, its parent
object could be set. I don't know how a heirarchy like this might affect
performance.

So a Unit could get the map data by using something like

Squad = Unit.Parent 'Get the squad the unit is in
Player = Squad.Parent 'Get the Player that owns the squad
Map = Player.Parent 'Get the map object for the player
Game = Map.Parent 'Get the game object for that map

There may be better ways, though

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Nov 20 '05 #5
Yes, that can be a solution, or even better to make a parent or grand parent
reference only in the classes that need it....
But I was wander if there could be a way to get this automatically without
my concern, but I guess a child class have no ideea about a parent that hold
it's reference
--
Cheers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"Chris Dunaway" <dunawayc@_lunchmeat_sbcglobal.net> wrote in message
news:nc*****************************@40tude.net...
On Thu, 15 Jan 2004 09:47:30 +0200, Crirus wrote:
the players are indeed childs of game.. was a TAB missing there
Map is a separate class only with data of the terrain
Players join to game not to map in my design

How to traverse up such a graph?


My only thought on that would be that each object would have a "parent"
property or perhaps a "ContainedBy" proprty that contains a reference to
the object that contains them. As each object is created, its parent
object could be set. I don't know how a heirarchy like this might affect
performance.

So a Unit could get the map data by using something like

Squad = Unit.Parent 'Get the squad the unit is in
Player = Squad.Parent 'Get the Player that owns the squad
Map = Player.Parent 'Get the map object for the player
Game = Map.Parent 'Get the game object for that map

There may be better ways, though

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.

Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Ernst Murnleitner | last post by:
Dear Readers, Is it possible to forbid conversion from this or use of this in general except where it is explicitly wanted? Reason: I changed my program from using normal pointers to...
0
by: John Phelan | last post by:
I have created a front-end application and back-end database. Everytime that I opened the program in the past, it open just fine with no errors when linking to the back-end tables. lately, I get...
0
by: John Phelan Cummings | last post by:
I have created a front-end application and back-end database. Everytime that I opened the program in the past, it open just fine with no errors when linking to the back-end tables. Lately, I...
4
by: John Phelan | last post by:
I have created a front-end application and back-end database. I have code that automatically links the front-end application to the back-end database for whenever I provide a patch or upgrade....
4
by: John Phelan | last post by:
Continue to get error message. Here is an update of my problem and everything that I have done to correct it. I have created a front-end application and back-end database. I have code that...
9
by: Hasan O. Zavalsiz | last post by:
Hi , i am trying to figure out which approach is better to use . let me explain the scenario. i am using the "Nortwind" database . in this database i have "Customers " table .The following is the...
94
by: Samuel R. Neff | last post by:
When is it appropriate to use "volatile" keyword? The docs simply state: " The volatile modifier is usually used for a field that is accessed by multiple threads without using the lock...
11
by: letz | last post by:
Hi, We have a class whose objects are to be allocated in shared memory. To do that a ShmManager base class is defined so that operator new and delete are redefined to allocate segments in shared...
11
by: =?ISO-8859-1?Q?Une_B=E9v?==?ISO-8859-1?Q?ue?= | last post by:
lets say i have two objects with the same properties and rge same values : var o1={element:one, type:'keyup',code:82,action:setToRed}; var o2={element:one, ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.