Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualblackfe2010

Posted 02 November 2012 - 08:38 AM

why does the Component class need to talk to the "Object Manager"? I would question the necessity of an "Object Manager" class.


Because i want Component can communicate to other Components
class Component
{
public:
  void sendMessage(string str)
  {
	m_objectManager->sendGlobalMessage(str);
  }
};
class ObjectManager
{
pubic:
  void sendGlobalMessage(string str)
  {
	  for_each(m_allComponents.begin(),m_allComponents.end(),...);
  }
};

And about the weak_ptr<>, you means i should do something like:
class Component
{
  boost::weak_ptr<ObjectManager> m_ojbectManager;
};
right?
but weak_ptr haven't operator -> how can i use it?

#2blackfe2010

Posted 02 November 2012 - 08:26 AM

why does the Component class need to talk to the "Object Manager"? I would question the necessity of an "Object Manager" class.


Because i want Component can communicate to other Components
class Component
{
public:
  void sendMessage(string str)
  {
	m_objectManager->sendGlobalMessage(str);
  }
};
class ObjectManager
{
pubic:
  void sendGlobalMessage(string str)
  {
	  for_each(m_allComponents.begin(),m_allComponents.end(),...);
  }
};

And about the weak_ptr<>, you means i should do something like:
class Component
{
  boost::weak_ptr<ObjectManager> m_ojbectManager;
};
right?

#1blackfe2010

Posted 02 November 2012 - 08:24 AM

why does the Component class need to talk to the "Object Manager"? I would question the necessity of an "Object Manager" class.


Because i want Component can communicate to other Components
class Component
{
public:
  void sendMessage(string str)
  {
    m_objectManager->sendGlobalMessage(str);
  }
};
class ObjectManager
{
pubic:
  void sendGlobalMessage(string str)
  {
	  for_each(m_allComponents.begin(),m_allComponents.end(),Callback...);
  }
};

And about the weak_ptr<>, you means i should do something like:
class Component
{
  boost::weak_ptr<ObjectManager> m_ojbectManager;
};
right?

PARTNERS