Advertisement
Guest User

Managed class function

a guest
Oct 9th, 2013
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.25 KB | None | 0 0
  1. void Company::Wrappers::CompanyDevicePhMgd::SetStructureVectors()
  2. {
  3.     CompanyDevicePh * device = GetImpObj();
  4.     device->vSconnections.clear();
  5.     for(int i = 0 ; i < vSconnections->Count ; i++)
  6.     {
  7.         StraightConnection connection;
  8.         AcDbHandle handle(vSconnections[i]->HandlePlume.Value);
  9.         connection.HandlePlume = handle;
  10.         connection.Priority = vSconnections[i]->Priority;
  11.         device->vSconnections.push_back(connection);
  12.     }
  13.     device->StraightConnectionSize = vSconnections->Count;
  14.     device->vPlumesCoords.clear();
  15.     for(int i = 0 ; i < vPlumesCoords->Count ; i++)
  16.     {
  17.         PlumePositionInformation inf;
  18.         AcDbHandle handle(vPlumesCoords[i]->PlumeHandle.Value);
  19.         inf.PlumeHandle = handle;
  20.         inf.Id = vPlumesCoords[i]->Id;
  21.         inf.Position = vPlumesCoords[i]->Position;
  22.         inf.ConnectedWithBase = vPlumesCoords[i]->ConnectedWithBase;
  23.         inf.IsStraight = vPlumesCoords[i]->IsStraight;
  24.         inf.SideDevicesSize = vPlumesCoords[i]->SideDevices->Count;
  25.         for(int j = 0 ; j < vPlumesCoords[i]->SideDevices->Count ; j++)
  26.         {
  27.             AcDbHandle firstHandle(vPlumesCoords[i]->SideDevices[j]->Key.Value);
  28.             AcDbHandle secondHandle(vPlumesCoords[i]->SideDevices[j]->Value.Value);
  29.             SideDevicesInfo pair;
  30.             pair.Key = firstHandle;
  31.             pair.Value = secondHandle;
  32.             for(int z = 0; z<  vPlumesCoords[i]->SideDevices[j]->PlugInfo->Count; z++)
  33.             {
  34.                 TerminalInfo newInf;
  35.                 TerminalInfoMgd ^ etalonInfo = vPlumesCoords[i]->SideDevices[j]->PlugInfo[z];
  36.                 newInf.FirstDevContactId = etalonInfo->FirstDevContactId;
  37.                 newInf.FirstDeviceTerminalId = etalonInfo->FirstDeviceTerminalId;
  38.                 newInf.SecDevContactId = etalonInfo->SecDevContactId;
  39.                 newInf.SecondDeviceTerminalId = etalonInfo->SecondDeviceTerminalId;
  40.                 pair.PlugInfo.push_back(newInf);
  41.             }
  42.             pair.plugInfoSize = vPlumesCoords[i]->SideDevices[j]->PlugInfo->Count;
  43.             inf.SideDevices.push_back(pair);
  44.         }
  45.         device->vPlumesCoords.push_back(inf);
  46.     }
  47.     device->PlumeCoordsSize = vPlumesCoords->Count;
  48.     device->vProperties.clear();
  49.     DWORD err;
  50.     for(int i = 0 ; i < vProperties->Count ; i++)
  51.     {
  52.         Property prop;
  53.         /*prop.Name = new wchar_t[100];
  54.         prop.Name[0] = L'\0';
  55.         wcscat(prop.Name,MStringToWchar(vProperties[i]->Name));*/
  56.         //delete prop.Name;
  57.         if(prop.Name != NULL)
  58.             delete [] prop.Name;
  59.         prop.Name = new wchar_t[100];
  60.         //err = GetLastError();
  61.         MStringToWchar(vProperties[i]->Name,prop.Name);
  62.         prop.NameLen = wcslen(prop.Name);
  63.         switch(vProperties[i]->Type)
  64.         {
  65.         case doubleType :
  66.             prop.Type = ValType::doubleType;
  67.             prop.DoubleVal = vProperties[i]->DoubleVal;
  68.             prop.IntVal = -1;
  69.             prop.StrValLen = -1;
  70.             break;
  71.         case intType:
  72.             prop.Type = ValType::intType;
  73.             prop.IntVal = vProperties[i]->IntVal;
  74.             prop.DoubleVal = -1;
  75.             prop.StrValLen = -1;
  76.             break;
  77.         case stringType:
  78.             prop.Type = ValType::stringType;
  79.             //delete  prop.StrVal;
  80.             if(prop.StrVal != NULL)
  81.                 delete [] prop.StrVal;
  82.             prop.StrVal = new wchar_t[50];
  83.             //err = GetLastError();
  84.             MStringToWchar(vProperties[i]->StrVal,prop.StrVal);
  85.             /*prop.StrVal = new wchar_t[100];
  86.             prop.StrVal[0] = L'\0';
  87.             wcscat(prop.StrVal, MStringToWchar(vProperties[i]->StrVal));*/
  88.             prop.StrValLen = wcslen(prop.StrVal);
  89.             prop.DoubleVal = -1;
  90.             prop.IntVal = -1;
  91.             break;
  92.         }
  93.         device->vProperties.push_back(prop);
  94.     }
  95.     device->vTerminals.clear();
  96.     for(int i = 0 ; i < vTerminals->Count ; i++)
  97.     {
  98.         Terminal terminal;
  99.         terminal.Id = vTerminals[i]->Id;
  100.         terminal.isConnected = vTerminals[i]->isConnected;
  101.         terminal.ContactsSize = vTerminals[i]->vContacts->Count;
  102.         terminal.SectionArea = vTerminals[i]->SectionArea;
  103.         //delete terminal.Name;
  104.         terminal.Name = new wchar_t[50];
  105.         err = GetLastError();
  106.         MStringToWchar(vTerminals[i]->Name,terminal.Name);     
  107.         terminal.namelen = wcslen(terminal.Name);
  108.         for(int b = 0; b < terminal.namelen;b++)
  109.         {
  110.             terminal.Test[b] = terminal.Name[b];
  111.         }
  112.        
  113.        
  114.         terminal.Type = new wchar_t[50];
  115.         acutPrintf(L"%p %p",terminal.Type,terminal.Name);
  116.         err = GetLastError();
  117.         MStringToWchar(vTerminals[i]->Type,terminal.Type);     
  118.         terminal.TypeLen = wcslen(terminal.Type);
  119.         for(int j = 0 ; j < vTerminals[i]->vContacts->Count ; j++)
  120.         {
  121.             Contact contact;
  122.             ///////allocation here
  123.             contact.ContactName = new wchar_t[50];
  124.             contact.TypeName = new wchar_t[50];
  125.             contact.IsConnected = vTerminals[i]->vContacts[j]->IsConnected;
  126.             contact.Id =  vTerminals[i]->vContacts[j]->Id;
  127.             MStringToWchar(vTerminals[i]->vContacts[j]->ContactName,contact.ContactName);
  128.             MStringToWchar(vTerminals[i]->vContacts[j]->TypeName,contact.TypeName);
  129.            
  130.             contact.namelen = wcslen(contact.ContactName);
  131.             contact.TypeNameLen = wcslen(contact.TypeName);
  132.             contact.ContactNumber = vTerminals[i]->vContacts[j]->ContactNumber;
  133.             for(int b = 0 ; b < vTerminals[i]->vContacts[j]->ConnectionInfo->Count; b++)
  134.             {
  135.                 MgdContactConnectionInfo ^ etInf =  vTerminals[i]->vContacts[j]->ConnectionInfo[b];
  136.                 ContactConnectionInfo nativeInf;
  137.                 nativeInf.ContactId = etInf->ContactId;
  138.                 nativeInf.TerminalId = etInf->TerminalId;
  139.                 AcDbHandle shandle(etInf->SwitchingDevice.Value);
  140.                 nativeInf.SwitchingDevice = shandle;
  141.                 contact.ConnectionInfo.push_back(nativeInf);
  142.             }
  143.             contact.ConnectionsSize = contact.ConnectionInfo.size();
  144.             terminal.vContacts.push_back(contact);
  145.         }
  146.        
  147.     }
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement