示例#1
0
TypeStruct* CDeviceTypeDirectory::addType(const TypeStruct& otherTypeStruct,int entityNumber)
{
   TypeStruct* typeStruct = m_deviceTypeList.addType(otherTypeStruct,entityNumber);

   // if more than one type has the same name, the last added type is in the map
   getDeviceTypeMap().add(typeStruct->getName(),typeStruct);

   return typeStruct;
}
示例#2
0
void CDeviceTypeDirectory::reallocateMap() const
{
   delete m_deviceTypeMap;

   int size = max(100,(int)(1.3 * m_deviceTypeList.GetCount()));

   m_deviceTypeMap = new CDeviceTypeArrayWithMap(size,false);

   for (POSITION pos = m_deviceTypeList.GetHeadPosition();pos != NULL;)
   {
      TypeStruct* typeStruct = m_deviceTypeList.GetNext(pos);
      m_deviceTypeMap->add(typeStruct->getName(),typeStruct);
   }
}
示例#3
0
// does not copy the CTypePinList
TypeStruct::TypeStruct(const TypeStruct& other,int entityNumber)
: m_parentList(other.m_parentList)
, m_attributes(NULL)
, m_blockNumber(other.getBlockNumber())
, m_entityNumber(entityNumber)
, m_name(other.getName())
, m_typePinList(*this)
{
   if (m_entityNumber < 0)
   {
      m_entityNumber = getCamCadData().allocateEntityNumber();
   }

   if (other.getAttributes() != NULL)
   {
      attributes() = *(other.getAttributes());
   }
}
示例#4
0
void CDeviceTypeDirectory::deleteAt(POSITION pos)
{
   TypeStruct* listTypeStruct = getAt(pos);

   if (m_deviceTypeMap != NULL)
   {
      TypeStruct* mapTypeStruct = getDeviceTypeMap().getAt(listTypeStruct->getName());

      // If the map contains a different TypeStruct, no need to deallocate map.
      // If the map contains this TypeStruct, deallocate it so that when it is rebuilt, another TypeStruct with the same name
      // will be put into the map.
      if (mapTypeStruct == listTypeStruct)
      {
         deallocateMap();
      }
   }

   m_deviceTypeList.deleteAt(pos);
}
示例#5
0
TypeStruct* CDeviceTypeList::findType(const CString& name) const
{
   TypeStruct* typeStruct = NULL;

   for (POSITION pos = m_typeList.GetHeadPosition();;)
   {
      if (pos == NULL)
      {
         typeStruct = NULL;
         break;
      }

      typeStruct = m_typeList.GetNext(pos);

      if (typeStruct->getName().Compare(name) == 0)
      {
         break;
      }
   }

   return typeStruct;
}