示例#1
0
bool ListReaderH5::FillInDataT (T *a_)
{
  listReader_GetMapId().clear();
  // we only have to do this the first time
  GetVersion();
  // need to read this in case they have 0 in the first stress period
  //if (m_stress == 1)
  //{
    for (int i=0; i<m_nRows*m_nFields; i++)
      a_[i] = 0.0;
    // fill in cell k i j
    if (!GetCellKIJ(a_))
      return false;
    // fill in the auxilary values like IFACE and 
    // cellgrp (for post processing CCF)
    if (m_nAuxFields > 0)
    {
      if (GetAuxIdx("IFACE") > -1)
      {
        if (!GetIface(a_))
          return false;
      }
      char* factStr[4] = { "CONDFACT", "QFACT", "SHEADFACT", "EHEADFACT"};
      int   factFlg[4] = {          0,       0,           1,           2};
      for (int i = 0; i < 4; ++i)
      {
        int index = GetAuxIdx(factStr[i]);
        if (index > -1)
        {
          if (!GetFactor(a_, index, factFlg[i]))
            return false;
        }
      }
      if (GetAuxIdx("CELLGRP") > -1)
      {
        if (!GetCellGroup(a_))
          return false;
      }
      GetSeawatAux(a_);
      GetUsgTransportAux(a_);
    }
    ASSERT(_CrtCheckMemory());
  //}

  // fill in the boundary condition values like head, conductance, elevation
  return (GetStressData(a_));
} // ListReaderH5::FillInData
void enum_interfaces( HDATA Data, InterfaceMetadata *pOut, tDWORD* p_iface_count ) 
{

	tDWORD size;
	tDWORD icount;
	tDWORD i;
	tERROR error;
    tCODEPAGE plugin_codepage;

    if ( p_iface_count )
		*p_iface_count = 0;

	prop_iface_count( Data, &size, (tCHAR*)&icount, sizeof(tDWORD) );

    if (p_iface_count != 0)
	  *p_iface_count = icount;

	if (pOut == 0)
		return;

    error = GetDwordPropVal(Data,0,VE_PID_PL_CODEPAGEID, &plugin_codepage );

    if ( PR_FAIL ( error ) ) {
      PR_TRACE(( this, prtNOTIFY, "(%terr): cannot get iface CODEPAGE id from metadata (plugin = \"%s\"(\"%s\"), iface number = %u, %tiid, %tpid", error, m_name, comment, i-1, iid, pid ) );
      plugin_codepage = cCP_ANSI;
    }

	for( i=0; i<icount; i++ ) 
	{
				
		tIID iid;
		
        error = GetInterfaceProperty(Data, 0, i, pgINTERFACE_ID, &iid, sizeof(iid) ); // index zero is for the plugin properties
		if ( PR_FAIL(error) ) 
		{ 
			PR_TRACE(( this, prtERROR, "Error reading iface description (plugin = \"%s\", iface item number - %u, %terr)", m_name, i-1, error ));
		}
		else if ( (iid == IID_ANY) || (iid == IID_NONE) ) 
		{
			continue;
		}
		else 
		{
			tPID     pid;
			tDWORD   sub;
			tVERSION ver;
			tVID     vid;
			tDWORD   flags;
			tIID     compat;
            tCODEPAGE codepage;

			if ( PR_SUCC(error=GetInterfaceProperty(Data, 0,i, pgPLUGIN_ID,&pid,sizeof(pid))) ) // plugin ID
			{

				if ( PR_FAIL(error=GetInterfaceProperty(Data, 0,i,pgINTERFACE_SUBTYPE,&sub,sizeof(sub))) ) {// subtype of interface in plugin
					sub = 0;
					PR_TRACE(( this, prtERROR, "(%terr): error in metadata: cannot get subtype (plugin = \"%s\"(\"%s\"), iface number = %u, %tiid, %tpid", error, m_name, comment, i-1, iid, pid ) );
				}

				if ( PR_FAIL(error=GetInterfaceProperty(Data, 0,i,pgINTERFACE_VERSION,&ver,sizeof(ver))) ) { // version
					ver = 1;
					PR_TRACE(( this, prtIMPORTANT, "(%terr): error in metadata: cannot get iface VERSION from metadata (plugin = \"%s\"(\"%s\"), iface number = %u, %tiid, %tpid", error, m_name, comment, i-1, iid, pid ) );
				}

				if ( PR_FAIL(error=GetInterfaceProperty(Data, 0,i,pgVENDOR_ID,&vid,sizeof(vid))) ) { // vendor id
					vid = VID_KASPERSKY_LAB;
					PR_TRACE(( this, prtNOTIFY, "(%terr): error in metadata: cannot get VENDOR ID from metadata (plugin = \"%s\"(\"%s\"), iface number = %u, %tiid, %tpid", error, m_name, comment, i-1, iid, pid ) );
				}

				if ( PR_FAIL(error=GetInterfaceProperty(Data, 0,i,pgINTERFACE_FLAGS,&flags,sizeof(flags))) ) { // interface flags
					flags = 0;
					PR_TRACE(( this, prtNOTIFY, "(%terr): error in metadata: cannot get iface FLAGS from metadata (plugin = \"%s\"(\"%s\"), iface number = %u, %tiid, %tpid", error, m_name, comment, i-1, iid, pid ) );
				}
				
				if ( PR_FAIL(error=GetInterfaceProperty(Data, 0,i,pgINTERFACE_COMPATIBILITY,&compat,sizeof(compat))) ) { // interface compatibility
					compat = PID_ANY;
					PR_TRACE(( this, prtNOTIFY, "(%terr): cannot get iface COMPATIBILITY id from metadata (plugin = \"%s\"(\"%s\"), iface number = %u, %tiid, %tpid", error, m_name, comment, i-1, iid, pid ) );
				}
                
                if ( PR_FAIL(error=GetInterfaceProperty(Data, 0,i,pgINTERFACE_CODEPAGE,&codepage,sizeof(codepage))) ) { // interface code page
					codepage = plugin_codepage;
					PR_TRACE(( this, prtNOTIFY, "(%terr): cannot get iface CODEPAGE id from metadata (plugin = \"%s\"(\"%s\"), iface number = %u, %tiid, %tpid", error, m_name, comment, i-1, iid, pid ) );
				}

                HDATA iface = GetIface ( Data, i );  
               	enum_static_properties(iface, 0, & pOut [i].theStaticPropertiesCount );
	            if ( pOut[i].theStaticPropertiesCount )
	            {
		          if ( !pOut[i].allocateStaticProperties () )
                    return;
		          enum_static_properties(iface, pOut[i].theStaticProperties, 0);
	            }
		        pOut[i].thePID = pid;
		        pOut[i].theSub = sub;
		        pOut[i].theVersion = ver;
		        pOut[i].theVID = vid;
		        pOut[i].theIID = iid;
		        pOut[i].theFlags = flags;
		        pOut[i].theCompat = compat;
                pOut[i].theCodePage = codepage;
      }
    }
  } 
  
  return;
}
tERROR GetInterfaceProperty( HDATA Data, tDWORD* result, tDWORD index, tPROPID prop_id, tPTR buffer, tDWORD count ) 
{
	tERROR error;
	tDWORD ret_val = 0;
	HDATA info;

	info = GetIface(Data, index);

	PR_TRACE_A0( this, "Enter Plugin::GetInterfaceProperty method" );

	error = errOK;

#define PLUGIN_LEVEL(p) ( ((p)==pgPLUGIN_VERSION) || ((p)==pgPLUGIN_ID) || ((p)==pgVENDOR_ID) || ((p)==pgVENDOR_NAME) || ((p)==pgPLUGIN_NAME) )
   if ( PLUGIN_LEVEL(prop_id) )
    return GetPluginProp( Data, &ret_val, prop_id, buffer, count );


    if ( !info )
      error = errINTERFACE_NO_MORE_ENTRIES; //errINTERFACE_NOT_FOUND;
    else 
	{
      switch( prop_id ) 
	  {
        case pgINTERFACE_ID       :
        case pgINTERFACE_SUBTYPE  :
        case pgINTERFACE_FLAGS    :
        case pgINTERFACE_CODEPAGE :
          if ( buffer && (count < sizeof(AVP_dword)) )
            error = errBUFFER_TOO_SMALL;
          break;
        }

        if ( error == errOK ) {
          tDWORD val;
          switch( prop_id ) {
          case pgINTERFACE_ID       :
            if ( !GetDwordPropVal(info,0,VE_PID_IF_DIGITALID,(AVP_dword*)buffer) )
              error = errPROPERTY_NOT_FOUND;
            break;
          case pgINTERFACE_SUBTYPE  :
            if ( !GetDwordPropVal(info,0,VE_PID_IF_SUBTYPEID,(AVP_dword*)buffer) )
              error = errPROPERTY_NOT_FOUND;
            break;
          case pgINTERFACE_FLAGS    :
            *((tDWORD*)buffer) = 0;
            //if ( GetBoolPropVal(info,0,VE_PID_IF_STATIC) )
            //  *((tDWORD*)buffer) |= IFACE_STATIC;
            if ( GetBoolPropVal(info,0,VE_PID_IF_SYSTEM) )
              *((tDWORD*)buffer) |= IFACE_SYSTEM;
            if ( GetBoolPropVal(info,0,VE_PID_IF_TRANSFERPROPUP) )
              *((tDWORD*)buffer) |= IFACE_PROP_TRANSFER;
            if ( GetBoolPropVal(info,0,VE_PID_IF_NONSWAPABLE) )
              *((tDWORD*)buffer) |= IFACE_UNSWAPPABLE;
            if ( GetDwordPropVal(info,0,VE_PID_IF_PROTECTED_BY,(ULONG*)&val) ) {
              switch( val ) {
              case VE_IFF_PROTECTED_BY_CS    : *((tDWORD*)buffer) |= IFACE_PROTECTED_BY_CS;    break;
              case VE_IFF_PROTECTED_BY_MUTEX : *((tDWORD*)buffer) |= IFACE_PROTECTED_BY_MUTEX; break;
              case VE_IFF_PROTECTED_BY_NONE  :
              default                        : break;
              }
            }
            break;
          default :
            error = GetStaticIfacePropValByID( info, prop_id, buffer, count, (ULONG*)&count );
            break;
        }
      }
    }
  if ( result )
    *result = PR_SUCC(error) ? count : 0;

	if ( result )
		*result = ret_val;
	return error;
}