ObjectContainer.cpp
Go to the documentation of this file.
00001 /**********************************************************************************************/
00022 #include "lo/ObjectContainer.h"
00023 
00024 
00025 namespace jlo
00026 {
00035 ReturnMatrix ObjectContainer::Get ( )
00036 {
00037   if(m_semaStatic)
00038     return m_relativePosition;
00039   else
00040     throw "Not implemented";
00041 }
00042 
00043 ReturnMatrix ObjectContainer::GetInv ( )
00044 {
00045   if(m_semaStatic)
00046     return m_invRelativePosition;
00047   else
00048    throw "Not implemented";
00049 }
00050 
00051 void ObjectContainer::AddAttachedObject(ServiceLocatedObject* lo)
00052 {
00053   IncreaseReferenceCounter();
00054   m_attachedLocatedObjectList.push_back(lo);
00055   if(lo->GetLOType() != LO_TYPE_PHYSICAL)
00056   {
00057     TellParentNeedCopy();
00058   }
00059 }
00060 
00061 void ObjectContainer::RemoveAttachedObject(ServiceLocatedObject* lo)
00062 {
00063   std::vector<ServiceLocatedObject*>::iterator it = m_attachedLocatedObjectList.begin();
00064   for(;it!= m_attachedLocatedObjectList.end(); )
00065   {
00066      if((*it)->m_uniqueID == lo->m_uniqueID)
00067      {
00068        it = m_attachedLocatedObjectList.erase(it);
00069        DecreaseReferenceCounter();
00070      }
00071      else
00072        it++;
00073   }
00074 }
00075 
00076 
00077 bool ObjectContainer::NeedCopy()
00078 {
00079   /*bool needCopy = false;
00080   std::vector<ServiceLocatedObject*>::iterator it = m_attachedLocatedObjectList.begin();
00081   for(;it!= m_attachedLocatedObjectList.end() && !needCopy; it++)
00082   {
00083      if((*it)->GetLOType() == LO_TYPE_PHYSICAL)
00084      {
00085        needCopy = (*it)->NeedCopy();
00086      }
00087      else
00088      {
00089        needCopy = true;
00090      }
00091   }*/
00092   return m_needCopy > 0;
00093 }
00094 
00095 void ObjectContainer::PropagateMovement(ServiceLocatedObject*(*copy)(ServiceLocatedObject*, ServiceLocatedObject*),
00096                           unsigned long (*del)(ServiceLocatedObject*), void (*updated)(unsigned long), ServiceLocatedObject* parent)
00097 {
00098   updated(m_uniqueID);
00099   ObjectContainer* copyOfThis = NULL;
00100   bool needCopy = NeedCopy();
00101   if(!needCopy)
00102     return;
00103   m_needCopy = 0;
00104   std::vector<ServiceLocatedObject*>::iterator it = m_attachedLocatedObjectList.begin();
00105   for(;it!= m_attachedLocatedObjectList.end(); )
00106   {
00107     if((*it)->GetLOType() != LO_TYPE_PHYSICAL)
00108     {
00109       if(copyOfThis == NULL)
00110       {
00111         copyOfThis = (ObjectContainer*)(*copy)(this, parent);
00112       }
00113 
00114       copyOfThis->AddAttachedObject(*it);
00115       (*it)->m_parentID = copyOfThis->m_uniqueID;
00116       (*it)->m_relation = copyOfThis;
00117       it = m_attachedLocatedObjectList.erase(it);
00118     }
00119     else
00120     {
00121       if(copyOfThis == NULL)
00122       {
00123         copyOfThis = (ObjectContainer*)(*copy)(this, parent);
00124       }
00125       (*it)->PropagateMovement(copy, del, updated, copyOfThis);
00126       it++;
00127     }
00128   }
00129   del(copyOfThis);
00130 }
00131 
00132 
00133 unsigned long ObjectContainer::Move (const Matrix &matrix, const Matrix &covMatrix)
00134 {
00135         return RELOCATE_OBJECT;
00136 }
00137 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


lo
Author(s): U. Klank
autogenerated on Thu May 23 2013 07:34:46