LDicomAssociate::IsRoleSelect

#include "ltdic.h"

L_BOOL LDicomAssociate::IsRoleSelect(nID)

L_UCHAR nID;

/* presentation ID */

Determines whether Role Selection is enabled for the specified Presentation Context of the DICOM Associate.

Parameter

Description

nID

Presentation ID of the Presentation Context for which you wish to check Role Selection. The presentation ID provides information about both the class type of the data and the transfer syntax to use when transferring the data. It also identifies a specific Presentation Context within an Associate.

Returns

TRUE

Role Selection is enabled for the specified Presentation Context of the DICOM Associate.

FALSE

Role Selection is disabled for the specified Presentation Context of the DICOM Associate.

Comments

If Role Selection is enabled, the role of the specified Presentation Context can be retrieved using LDicomAssociate::GetUserRole and LDicomAssociate::GetProviderRole. To set the role of the specified Presentation Context, use LDicomAssociate::SetRoleSelect.

Required DLLs and Libraries

LTDIC

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application

See Also

Functions:

LDicomAssociate::GetUserRole, LDicomAssociate::GetProviderRole, LDicomAssociate::SetRoleSelect

Topics:

Working with DICOM Associate Connections

Example

{
  //This example builds an associate request (pointed to by pAssociateAll) 
   //that contains all the abstract syntaxes
  //present in m_pDicomAssociate, and adds all the abstract syntaxes not present in m_pDicomAssociate.
  //Each abstract syntax that was not in m_pDicomAssociate is given a default presentation context
  //
  //m_pDicomAssociate is a member variable declared as:
  //   LDicomAssociate *m_pDicomAssociate;

   L_UCHAR    nID, nIDtemp;
   pDICOMUID pUID;
   CString strAbstractSyntax;
   L_INT i, j;
   LDicomAssociate *pAssociateAll;
   CString strMsg;
   CString strTmp;
   
   //Create the new associate object
   pAssociateAll =new LDicomAssociate(TRUE);

   nIDtemp = 1;
   pUID = LDicomUID::GetFirst();
   while (pUID != NULL)
   {
      if ((pUID->nType == UID_TYPE_CLASS) || (pUID->nType == UID_TYPE_META_CLASS))
      {
         pAssociateAll->AddPresentation(nIDtemp, 0, pUID->pszCode);
         nIDtemp += 2;
      }
      pUID = LDicomUID::GetNext(pUID);
   }
   
   
   for (i = 0; i < pAssociateAll->GetPresentationCount(); i++)
   {
      nIDtemp = pAssociateAll->GetPresentation(i);
      strAbstractSyntax = pAssociateAll->GetAbstract(nIDtemp);
      nID = m_pDicomAssociate->FindAbstract((L_CHAR *)(LPCTSTR)strAbstractSyntax);
      
      //if abstract not found in m_pDicomAssociate, add default transfer syntaxes so that 
      //the abstract syntax will not be rejected by the server
      if (nID == 0)  
      {
         pUID =  LDicomUID::GetFirst();
         while (pUID != NULL)
         {
            if (pUID->nType == UID_TYPE_TRANSFER1)
            {
               pAssociateAll->AddTransfer(nIDtemp, pUID->pszCode);
            }
            
            pUID = LDicomUID::GetNext(pUID);
         }
      }
      
      //abstract found in hAssociateRequest
      //add transfer syntaxes for the abstract syntax found in hAssociateRequest
      else  
      {
         for (j = 0; j < m_pDicomAssociate->GetTransferCount(nID); j++)
         {
            CString strTransferSyntax =  m_pDicomAssociate->GetTransfer(nID, j);
            pAssociateAll->AddTransfer(nIDtemp, (L_CHAR *)(LPCTSTR)strTransferSyntax);
         }
         
         pAssociateAll->SetRoleSelect(
            nIDtemp, 
            m_pDicomAssociate->IsRoleSelect(nID), 
            m_pDicomAssociate->GetUserRole(nID), 
            m_pDicomAssociate->GetProviderRole(nID)
            );
         
         pAssociateAll->SetExtended(
            nIDtemp, 
            m_pDicomAssociate->GetExtended(nID), 
            m_pDicomAssociate->GetLengthExtended(nID)
            );
      }
   }

   //Display each abstract syntax (and some presentation context info) for pAssociateAll object
   strMsg = "AssociateAll:";
   for (i=0; i<pAssociateAll->GetPresentationCount(); i++)
   {
      nIDtemp = pAssociateAll->GetPresentation(i);
      strAbstractSyntax = pAssociateAll->GetAbstract(nIDtemp);
      pUID = LDicomUID::Find((L_CHAR *)(LPCTSTR)strAbstractSyntax);
      strMsg = strMsg + "\n" + pUID->pszName;
      if (pAssociateAll->IsRoleSelect(nIDtemp))
      {
         L_UCHAR uUserRole = pAssociateAll->GetUserRole(nIDtemp);
         L_UCHAR uProviderRole = pAssociateAll->GetProviderRole(nIDtemp);
         strTmp.Format("UserRole[%d]    ProviderRole[%d]", uUserRole, uProviderRole);
         strMsg = strMsg + strTmp;
      }
   }
   AfxMessageBox(strMsg);
}