Exemplo n.º 1
0
static void
Enumerate(struct Strbuf *buf, const XmapNode *ptr)
{
    size_t old_len;

    if (ptr == NULL) {
#ifdef DEBUG_EDIT
	xprintf(CGETS(9, 6, "Enumerate: BUG!! Null ptr passed\n!"));
#endif
	return;
    }

    old_len = buf->len;
    unparsech(buf, ptr->ch); /* put this char at end of string */
    if (ptr->next == NULL) {
	/* print this Xkey and function */
	Strbuf_append1(buf, '"');
	Strbuf_terminate(buf);
	printOne(buf->s, &ptr->val, ptr->type);
    }
    else
	Enumerate(buf, ptr->next);

    /* go to sibling if there is one */
    if (ptr->sibling) {
	buf->len = old_len;
	Enumerate(buf, ptr->sibling);
    }
}
Exemplo n.º 2
0
XnStatus XnSensorIO::EnumerateSensors(XnConnectionString* aConnectionStrings, XnUInt32* pnCount)
{
    XnStatus nRetVal = XN_STATUS_OK;

    nRetVal = xnUSBInit();
    if (nRetVal != XN_STATUS_OK && nRetVal != XN_STATUS_USB_ALREADY_INIT)
        return nRetVal;

// Temporary patch: "Cache" the devices since running USB enum on the MacOSX platform takes several seconds due to problems in libusb!
#if (XN_PLATFORM == XN_PLATFORM_MACOSX)
    static XnStringsHash devicesSet;

    if (devicesSet.Size() == 0)
    {
        // search for a v6.0.1 device
        nRetVal = Enumerate(XN_SENSOR_6_0_1_PRODUCT_ID, devicesSet);
        XN_IS_STATUS_OK(nRetVal);

        // search for a v6.0 device
        nRetVal = Enumerate(XN_SENSOR_6_0_PRODUCT_ID, devicesSet);
        XN_IS_STATUS_OK(nRetVal);
    }
#else
    XnStringsHash devicesSet;

    // search for a v6.0.1 device
    nRetVal = Enumerate(XN_SENSOR_6_0_1_PRODUCT_ID, devicesSet);
    XN_IS_STATUS_OK(nRetVal);

    // search for a v6.0 device
    nRetVal = Enumerate(XN_SENSOR_6_0_PRODUCT_ID, devicesSet);
    XN_IS_STATUS_OK(nRetVal);

    // search for a v5.0 device
    nRetVal = Enumerate(XN_SENSOR_5_0_PRODUCT_ID, devicesSet);
    XN_IS_STATUS_OK(nRetVal);
#endif

    // now copy back
    XnUInt32 nCount = 0;
    for (XnStringsHash::ConstIterator it = devicesSet.begin(); it != devicesSet.end(); ++it, ++nCount)
    {
        if (nCount < *pnCount)
        {
            strcpy(aConnectionStrings[nCount], it.Key());
        }
    }

    if (nCount > *pnCount)
    {
        *pnCount = nCount;
        return XN_STATUS_OUTPUT_BUFFER_OVERFLOW;
    }

    // All is good...
    *pnCount = nCount;
    return (XN_STATUS_OK);
}
XnStatus XnSensorIO::EnumerateSensors(XnConnectionString* aConnectionStrings, XnUInt32* pnCount)
{
	XnStatus nRetVal = XN_STATUS_OK;

	nRetVal = xnUSBInit();
	if (nRetVal != XN_STATUS_OK && nRetVal != XN_STATUS_USB_ALREADY_INIT)
		return nRetVal;

// Temporary patch: "Cache" the devices since running USB enum on the MacOSX platform takes several seconds due to problems in libusb!		
#if (XN_PLATFORM == XN_PLATFORM_MACOSX)	
	static XnStringsSet devicesSet;
	
	if (devicesSet.Size() == 0)
	{
		// search for supported devices
		for (XnUInt32 i = 0; i < ms_supportedProductsCount; ++i)
		{
			nRetVal = Enumerate(ms_supportedProducts[i], devicesSet);
			XN_IS_STATUS_OK(nRetVal);
		}
	}
#else
	XnStringsSet devicesSet;

	// search for supported devices
	for (XnUInt32 i = 0; i < ms_supportedProductsCount; ++i)
	{
		nRetVal = Enumerate(ms_supportedProducts[i], devicesSet);
		XN_IS_STATUS_OK(nRetVal);
	}
#endif
	
	// now copy back
	XnUInt32 nCount = 0;
	for (XnStringsSet::ConstIterator it = devicesSet.Begin(); it != devicesSet.End(); ++it, ++nCount)
	{
		if (nCount < *pnCount)
		{
			strcpy(aConnectionStrings[nCount], it->Key());
		}
	}

	if (nCount > *pnCount)
	{
		*pnCount = nCount;
		return XN_STATUS_OUTPUT_BUFFER_OVERFLOW;
	}

	// All is good...
	*pnCount = nCount;
	return (XN_STATUS_OK);
}
Exemplo n.º 4
0
BOOL C4GameObjects::Save(const char *szFilename, BOOL fSaveGame,
                         bool fSaveInactive) {
  // Enumerate
  Enumerate();
  InactiveObjects.Enumerate();
  Game.ScriptEngine.Strings.EnumStrings();

  // Decompile objects to buffer
  StdStrBuf Buffer;
  bool fSuccess = DecompileToBuf_Log<StdCompilerINIWrite>(
      mkParAdapt(*this, false, !fSaveGame), &Buffer, szFilename);

  // Decompile inactives
  if (fSaveInactive) {
    StdStrBuf InactiveBuffer;
    fSuccess &= DecompileToBuf_Log<StdCompilerINIWrite>(
        mkParAdapt(InactiveObjects, false, !fSaveGame), &InactiveBuffer,
        szFilename);
    Buffer.Append("\r\n");
    Buffer.Append(InactiveBuffer);
  }

  // Denumerate
  InactiveObjects.Denumerate();
  Denumerate();

  // Error?
  if (!fSuccess) return FALSE;

  // Write
  return Buffer.SaveToFile(szFilename);
}
Exemplo n.º 5
0
AEDeviceEnumerationOSX::AEDeviceEnumerationOSX(AudioDeviceID deviceID)
: m_deviceID(deviceID)
, m_isPlanar(false)
, m_caDevice(deviceID)
{
  Enumerate();
}
Exemplo n.º 6
0
CaptureDevices::CaptureDevices():
	enumMonikerVideo(NULL),
	enumMonikerAudio(NULL)
{
	CoInitialize(0);
	Enumerate();
}
Exemplo n.º 7
0
BOOL CMediaVisDlg::OnInitDialog()
{
	CString strMessage;

	CSkinDialog::OnInitDialog();

	SkinMe( L"CMediaVisDlg", ID_MEDIA_VIS );

	CRect rc;
	m_wndList.GetClientRect( &rc );
	rc.right -= GetSystemMetrics( SM_CXVSCROLL ) + 1;

	CoolInterface.SetImageListTo( m_wndList, LVSIL_SMALL );
	m_wndList.InsertColumn( 0, L"Description", LVCFMT_LEFT, rc.right, -1 );
	m_wndList.InsertColumn( 1, L"CLSID", LVCFMT_LEFT, 0, 0 );
	m_wndList.InsertColumn( 2, L"Subpath", LVCFMT_LEFT, 0, 1 );

	m_wndList.SetExtendedStyle( LVS_EX_FULLROWSELECT );

	m_nIcon = CoolInterface.ImageForID( ID_MEDIA_VIS );
	m_hIcon = CoolInterface.ExtractIcon( ID_MEDIA_VIS, FALSE );
	if ( m_hIcon )
		SetIcon( m_hIcon, FALSE );

	LoadString( strMessage, IDS_MEDIAVIS_NOVIS );
	AddPlugin( strMessage, NULL, NULL );
	Enumerate();

	m_nSize = Settings.MediaPlayer.VisSize + 1;
	UpdateData( FALSE );

	m_wndSetup.EnableWindow( m_wndList.GetSelectedCount() == 1 );

	return TRUE;
}
Exemplo n.º 8
0
                LxResult
        Enum (
                CLxImpl_AbstractVisitor *visitor)
        {
                CLxInst_OneVisitor<CLxGenericVisitor>  gv;

                gv.loc.vis = visitor;
                return Enumerate (gv);
        }
Exemplo n.º 9
0
                LxResult
        Enum (
                CLxImpl_AbstractVisitor *visitor,
                unsigned                 mask = LXfGRPTYPE_BOTH)
        {
                CLxInst_OneVisitor<CLxGenericVisitor>  gv;

                gv.loc.vis = visitor;
                return Enumerate (gv, mask);
        }
Exemplo n.º 10
0
bool ManhattanBranchAndBound::Compute(const vector<ManhattanEdge> edges[],
                                      function<void(const ManhattanBuilding&)> f) {
	visitor = f;
	Initialize(edges);
	if (init_hypotheses.empty()) {
		DLOG << "Warning: ManhattanBranchAndBound failed to generate initial hypotheses, aborting.";
		return false;
	}
	Enumerate();
}
Exemplo n.º 11
0
/*
========================
idSaveGameThread::Run
========================
*/
int idSaveGameThread::Run() {
	int ret = ERROR_SUCCESS;

	try {
		idLocalUserWin * user = GetLocalUserFromSaveParms( data );
		if ( user != NULL && !user->IsStorageDeviceAvailable() ) {
			data.saveLoadParms->errorCode = SAVEGAME_E_UNABLE_TO_SELECT_STORAGE_DEVICE;
		}

		if ( savegame_winInduceDelay.GetInteger() > 0 ) {
			Sys_Sleep( savegame_winInduceDelay.GetInteger() );
		}

		if ( data.saveLoadParms->mode & SAVEGAME_MBF_SAVE ) {
			ret = Save();
		} else if ( data.saveLoadParms->mode & SAVEGAME_MBF_LOAD ) {
			ret = Load();
		} else if ( data.saveLoadParms->mode & SAVEGAME_MBF_ENUMERATE ) {
			ret = Enumerate();
		} else if ( data.saveLoadParms->mode & SAVEGAME_MBF_DELETE_FOLDER ) {
			ret = Delete();
		} else if ( data.saveLoadParms->mode & SAVEGAME_MBF_DELETE_ALL_FOLDERS ) {
			ret = DeleteAll();
		} else if ( data.saveLoadParms->mode & SAVEGAME_MBF_DELETE_FILES ) {
			ret = DeleteFiles();
		} else if ( data.saveLoadParms->mode & SAVEGAME_MBF_ENUMERATE_FILES ) {
			ret = EnumerateFiles();
		}

		// if something failed and no one set an error code, do it now.
		if ( ret != 0 && data.saveLoadParms->errorCode == SAVEGAME_E_NONE ) {
			data.saveLoadParms->errorCode = SAVEGAME_E_UNKNOWN;
		}
	} catch ( ... ) {
		// if anything horrible happens, leave it up to the savegame processors to handle in PostProcess().
		data.saveLoadParms->errorCode = SAVEGAME_E_UNKNOWN;
	}

	// Make sure to cancel any save game file pipelines.
	if ( data.saveLoadParms->errorCode != SAVEGAME_E_NONE ) {
		data.saveLoadParms->CancelSaveGameFilePipelines();
	}

	// Override error if cvar set
	if ( savegame_error.GetInteger() != 0 ) {
		data.saveLoadParms->errorCode = (saveGameError_t)savegame_error.GetInteger();
	}

	// Tell the waiting caller that we are done
	data.saveLoadParms->callbackSignal.Raise();

	return ret;
}
Exemplo n.º 12
0
			static bool IsZombie(HWND hWnd)
			{
				if (!::GetParent( hWnd ))
				{
					hWnd = NULL;
					Enumerate( Callbacks::Find, &hWnd );

					if (hWnd)
						return true;
				}

				return false;
			}
Exemplo n.º 13
0
int _tmain(int argc, _TCHAR* argv[])
{
	printf("========================================================================\n");
	printf("TITLE:   IEEE 1394 DeviceID Tool, v0.0.2\n");
	printf("Author:  Thomas Pintaric, Vienna University of Technology\n");
	printf("Contact: [email protected], http://ims.tuwien.ac.at/~thomas\n");
	printf("========================================================================\n");
	printf("PLEASE NOTE: This program comes with ABSOLUTELY NO WARRANTY.\n");
	printf("This is free software, and you are welcome to redistribute it under\n");
	printf("certain conditions. See http://www.gnu.org/copyleft/gpl.html for details.\n\n");

	CoInitialize(NULL);
	HRESULT hr = Enumerate();
	CoUninitialize();
	return(hr);
}
Exemplo n.º 14
0
CPaCommon::CPaCommon(bool cap):ringBuffer(),xruns(0),stream(NULL),
        names(), devices(),
        is_capture(cap), blocking(true), device_changed(true), xrun(false),
        framesPerBuffer(0), ringBufferData(NULL)
{
    if (pa_count == 0)
    {
        int
        err = Pa_Initialize();
        if (err != paNoError)
            throw string("PortAudio error: ") + Pa_GetErrorText(err);
    }
    pa_count++;
    vector < string > choices;
    vector < string > descriptions;
    Enumerate(choices, descriptions);
}
Exemplo n.º 15
0
/* Lookup():
 *	look for the string starting at node ptr.
 *	Print if last node
 */
static int
Lookup(struct Strbuf *buf, const CStr *str, const XmapNode *ptr)
{
    if (ptr == NULL)
	return (-1);		/* cannot have null ptr */

    if (str->len == 0) {
	/* no more chars in string.  Enumerate from here. */
	Enumerate(buf, ptr);
	return (0);
    }
    else {
	/* If match put this char into buf.  Recurse */
	if (ptr->ch == *(str->buf)) {
	    /* match found */
	    unparsech(buf, ptr->ch);
	    if (ptr->next != NULL) {
		/* not yet at leaf */
		CStr tstr;
		tstr.buf = str->buf + 1;
		tstr.len = str->len - 1;
		return (Lookup(buf, &tstr, ptr->next));
	    }
	    else {
		/* next node is null so key should be complete */
		if (str->len == 1) {
		    Strbuf_append1(buf, '"');
		    Strbuf_terminate(buf);
		    printOne(buf->s, &ptr->val, ptr->type);
		    return (0);
		}
		else
		    return (-1);/* mismatch -- string still has chars */
	    }
	}
	else {
	    /* no match found try sibling */
	    if (ptr->sibling)
		return (Lookup(buf, str, ptr->sibling));
	    else
		return (-1);
	}
    }
}
Exemplo n.º 16
0
// OSErr find_files(
//	struct find_file_pb *param_block)
bool FileFinder::Find()
{
	// Translate the type info:
	type_to_find = (Type != WILDCARD_TYPE) ? get_typecode(Type) : 0;
	
	// Eliminated buffer creation as unused
	
	/* Assert that we got it. */
	assert(search_type==_callback_only || buffer);
	assert(version==0);

	/* Set the variables */
	count= 0;

	Enumerate(BaseDir);
	
	// Eliminated alphabetical order as unused
		
	return (Err == noErr);
}
Exemplo n.º 17
0
XnStatus XnSensorIO::EnumerateSensors(XnConnectionString* aConnectionStrings, XnUInt32* pnCount)
{
	XnStatus nRetVal = XN_STATUS_OK;
	XnBool bIsPresent = FALSE;

	nRetVal = xnUSBInit();
	if (nRetVal != XN_STATUS_OK && nRetVal != XN_STATUS_USB_ALREADY_INIT)
		return nRetVal;

	XnStringsHash devicesSet;

	// --avin mod--
	// search for a kinect device
	nRetVal = Enumerate(XN_SENSOR_PRODUCT_ID_KINECT, devicesSet);
	XN_IS_STATUS_OK(nRetVal);

	// now copy back
	XnUInt32 nCount = 0;
	for (XnStringsHash::ConstIterator it = devicesSet.begin(); it != devicesSet.end(); ++it, ++nCount)
	{
		if (nCount < *pnCount)
		{
			strcpy(aConnectionStrings[nCount], it.Key());
		}
	}

	if (nCount > *pnCount)
	{
		*pnCount = nCount;
		return XN_STATUS_OUTPUT_BUFFER_OVERFLOW;
	}

	// All is good...
	*pnCount = nCount;
	return (XN_STATUS_OK);
}
Exemplo n.º 18
0
//
// Create
//
HRESULT DX9Enumeration::Create( RenderInfo & renderInfo )
{
	// Store the Parameters
	AppMinFullscreenWidth = renderInfo.uiTargetWidth;
	AppMinFullscreenHeight = renderInfo.uiTargetHeight;
	AppMinColorChannelBits = renderInfo.uiTargetColorDepth == 16 ? 4 : 8;
	AppMinAlphaChannelBits = renderInfo.uiTargetColorDepth == 16 ? 4 : 8;
	AppRequiresWindowed = !renderInfo.bFullscreen;
	AppRequiresFullscreen = renderInfo.bFullscreen;
	AppRequiresReferenceDriver = renderInfo.bUseReferenceDriver;

#ifdef _DEBUG
	AppUsesMixedVP = true; // This is to allow debugging of HLSL
	ConfirmDeviceCallback = ConfirmDevice_SoftwareVP;
#else
	AppUsesMixedVP = false;
	ConfirmDeviceCallback = ConfirmDevice_HardwareVP;
#endif

	// Create the Direct3D Object
	m_pD3D = Direct3DCreate9( D3D_SDK_VERSION );
	if ( m_pD3D == NULL )
		return D3DAPPERR_NODIRECT3D;

	// Perform the enumeration
	if ( FAILED( Enumerate() ) )
		return E_FAIL;

	// Choose the best adapter based on if we want windowed or fullscreen mode
	if ( AppRequiresWindowed )
	{
		if ( !FindBestWindowedMode( !AppUsesMixedVP, AppRequiresReferenceDriver ) )
			return E_FAIL;
	}
	else
	{
		if ( !FindBestFullscreenMode( !AppUsesMixedVP, AppRequiresReferenceDriver  ) )
			return E_FAIL;
	}

	// From the D3DSettings, determine the parameters for the device
	D3DAdapterInfo* pAdapterInfo = m_d3dSettings.PAdapterInfo();
	D3DDeviceInfo* pDeviceInfo = m_d3dSettings.PDeviceInfo();
	bool bWindowed = m_d3dSettings.IsWindowed;
	HWND hWndFocus = (HWND)renderInfo.hMainWindow;

	DWORD behaviorFlags;
	if (m_d3dSettings.GetVertexProcessingType() == SOFTWARE_VP)
		behaviorFlags = D3DCREATE_SOFTWARE_VERTEXPROCESSING;
	else if (m_d3dSettings.GetVertexProcessingType() == MIXED_VP)
		behaviorFlags = D3DCREATE_MIXED_VERTEXPROCESSING;
	else if (m_d3dSettings.GetVertexProcessingType() == HARDWARE_VP)
		behaviorFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING;
	else if (m_d3dSettings.GetVertexProcessingType() == PURE_HARDWARE_VP)
		behaviorFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE;
	else
		behaviorFlags = 0; // TODO: throw exception

	// Set up the presentation parameters
	BuildPresentParamsFromSettings( renderInfo );

	// Create the D3D9 Device and return the result
	return m_pD3D->CreateDevice( m_d3dSettings.AdapterOrdinal(), 
								 pDeviceInfo->DevType,
								 hWndFocus, 
								 behaviorFlags, 
								 &m_d3dpp,
								 &m_pD3DDevice 
	);
}
Exemplo n.º 19
0
//
// Notes:
// xi: operation node xi whose id is i 
//
// i starts off at MAX_PORT_NU
//
void Enumerate(int *ASAP_slots, int *ALAP_slots, int i) {

  int first, last;
  int step;
  int cur_latency;
  int cur_mux_fanin;
  int cur_mux_fanout = 0;
  int cur_mux_input;
  int cur_muxp_input;
  int cur_muxr_input;
  int cur_reg_nu;
  int fuNu; // functional unit number
  static int best_latency = 100000;

  //------------------------------------------------------------
  // vars to support GenerateBackEnd
  char scheduleName[10];
  ScheduleStats SS[3]; // ASAP, ALAP, Iter
  //------------------------------------------------------------

  if (i == NODE_NU) {
    myprintf("enumeration hit the last node\n");

    CheckConflict(); 

    if (min_mux_fanin == 2) {
      fprintf(stderr, "\nfanin = 2\n");
      fprintf(stderr, "Cur Enum mux fanout (%d %d)\n", min_mux_fanout, max_mux_fanout);
      fprintf(stderr, "Cur Enum mux fanin (%d %d)\n", min_mux_fanin, max_mux_fanin);
      fprintf(stderr, "Cur Enum muxp input (%d %d)\n", min_muxp_input, max_muxp_input);
      fprintf(stderr, "Cur Enum muxr input (%d %d)\n", min_muxr_input, max_muxr_input);
      fprintf(stderr, "Cur Enum mux input (%d %d)\n", min_mux_input, max_mux_input);
      fprintf(stderr, "Cur Enum reg number(%d %d)\n", min_reg_nu, max_reg_nu);
      fprintf(stderr, "Cur Enum latency   (%d %d)\n", min_latency, max_latency);
      PrintDFG(ASAP_slots, ALAP_slots); exit(0);
    }

    if (max_mux_fanin == 6) {
      fprintf(stderr, "\nfanin = 6\n");
      fprintf(stderr, "Cur Enum mux fanout (%d %d)\n", min_mux_fanout, max_mux_fanout);
      fprintf(stderr, "Cur Enum mux fanin (%d %d)\n", min_mux_fanin, max_mux_fanin);
      fprintf(stderr, "Cur Enum muxp input (%d %d)\n", min_muxp_input, max_muxp_input);
      fprintf(stderr, "Cur Enum muxr input (%d %d)\n", min_muxr_input, max_muxr_input);
      fprintf(stderr, "Cur Enum mux input (%d %d)\n", min_mux_input, max_mux_input);
      fprintf(stderr, "Cur Enum reg number(%d %d)\n", min_reg_nu, max_reg_nu);
      fprintf(stderr, "Cur Enum latency   (%d %d)\n", min_latency, max_latency);
      //PrintDFG(ASAP_slots, ALAP_slots); exit(0);
    }

    ENUM_NU++;

    if (fmod(ENUM_NU, 1000) == 0) {
      //fprintf(stderr, "progress %lf%\n", ENUM_NU / ENUM_SZ * 100);
      fprintf(stderr, "progress %lf\n", ENUM_NU);
      fprintf(stderr, "Cur Enum mux fanout (%d %d)\n", min_mux_fanout, max_mux_fanout);
      fprintf(stderr, "Cur Enum mux fanin (%d %d)\n", min_mux_fanin, max_mux_fanin);
      fprintf(stderr, "Cur Enum muxp input (%d %d)\n", min_muxp_input, max_muxp_input);
      fprintf(stderr, "Cur Enum muxr input (%d %d)\n", min_muxr_input, max_muxr_input);
      fprintf(stderr, "Cur Enum mux input (%d %d)\n", min_mux_input, max_mux_input);
      fprintf(stderr, "Cur Enum reg number(%d %d)\n", min_reg_nu, max_reg_nu);
      fprintf(stderr, "Cur Enum latency   (%d %d)\n", min_latency, max_latency);

      printf("stopped at 10000\n"); exit(0);

      if (ENUM_NU > 1000000) return;
      //if (ENUM_NU == 60000) getchar();
    }

    // Debug spot

    // 
    cur_latency = DFG[NODE_NU-1]->opScheduledSlot + DFG[NODE_NU-1]->opLatency + 1;
    myprintf("current latency = %d\n", cur_latency);

    if (min_latency > cur_latency) {
      min_latency = cur_latency;
    }

    if (max_latency < cur_latency) {
      max_latency = cur_latency;
    }

    // 
    GenerateBackEnd(stderr, scheduleName, "Iter", PORT_NU, cur_latency, SS);

    if (cur_mux_fanout < CSP->rfo) cur_mux_fanout = CSP->rfo;
    if (cur_mux_fanout < CSP->pfo) cur_mux_fanout = CSP->pfo;
    if (cur_mux_fanout < CSP->ffo) cur_mux_fanout = CSP->ffo;

    cur_mux_fanin = CSP->fan;
    cur_mux_input = CSP->mux;
    cur_muxp_input = CSP->muxp;
    cur_muxr_input = CSP->muxr;
    cur_reg_nu    = CSP->reg;

    // best_mux_fanout
    if (min_mux_fanout > cur_mux_fanout) {
      min_mux_fanout = cur_mux_fanout;
    }

    if (max_mux_fanout < cur_mux_fanout) {
      max_mux_fanout = cur_mux_fanout;
    }

    // best_reg_nu
    if (min_reg_nu > cur_reg_nu) {
      min_reg_nu = cur_reg_nu;
    }

    if (max_reg_nu < cur_reg_nu) {
      max_reg_nu = cur_reg_nu;
    }

    // best_mux_input
    if (min_mux_input > cur_mux_input) {
      min_mux_input = cur_mux_input;
    }

    if (max_mux_input < cur_mux_input) {
      max_mux_input = cur_mux_input;
    }

    // best_muxp_input
    if (min_muxp_input > cur_muxp_input) {
      min_muxp_input = cur_muxp_input;
    }

    if (max_muxp_input < cur_muxp_input) {
      max_muxp_input = cur_muxp_input;
    }

    // best_muxr_input
    if (min_muxr_input > cur_muxr_input) {
      min_muxr_input = cur_muxr_input;
    }

    if (max_muxr_input < cur_muxr_input) {
      max_muxr_input = cur_muxr_input;
    }

    // best_mux_fanin
    if (min_mux_fanin > cur_mux_fanin) {
      min_mux_fanin = cur_mux_fanin;
    }

    if (max_mux_fanin < cur_mux_fanin) {
      max_mux_fanin = cur_mux_fanin;
    }
  }

  else {

      first = ASAP_slots[i];
      last = ALAP_slots[i];
    /*
    if (ASAP_slots[i] < ALAP_slots[i]) {
      first = ASAP_slots[i];
      last = ALAP_slots[i];
    } 
    else {
      // ALAP has shorter latency 
      first = ALAP_slots[i];
      last = ASAP_slots[i];

      // update ASAP/ALAP slots
      ASAP_slots[i] = first;
      ALAP_slots[i] = last;
    }
    */

    int step_size, step_range;

    assert(last >= first);

    step_range = last - first + 1;

    /* ordbbr
      if (step_range > 60)
        step_size = 30; //10;
      else if (step_range > 40)
        step_size = 20; //10;
      else  if (step_range > 30)
        step_size = 15; //8;
      else  if (step_range > 20)
        step_size = 10; //6;
      else  if (step_range > 10)
        step_size = 5;
      else  if (step_range > 2)
        step_size = 2;
      else 
        step_size = 1;

    // for ordbur, ppbr
      if (step_range > 40)
        step_size = 10;
      else  if (step_range > 30)
        step_size = 8;
      else  if (step_range > 20)
        step_size = 6;
      else  if (step_range > 10)
        step_size = 4;
      else  if (step_range > 2)
        step_size = 2;
      else 
        step_size = 1;
        */

        step_size = 1;

    myprintf("enum %lf debug mobility step: %d [%d %d]\n", ENUM_NU, step_size, first, last);

    //for (step = first; step <= last; step++) {
    for (step = first; step <= last; step += step_size) {

      myprintf("Try step %d of DFG node %d [%d %d]\n", step, i, first, last);

      // save ASAP values
      int *save_ASAP_slots = (int *) malloc (sizeof(int) * NODE_NU);
      int *save_ALAP_slots = (int *) malloc (sizeof(int) * NODE_NU);
      memcpy(save_ASAP_slots, ASAP_slots, NODE_NU * sizeof(int));
      memcpy(save_ALAP_slots, ALAP_slots, NODE_NU * sizeof(int));

      // ResourceUsed (step, type(xi))
      // Increment ResourceUsed (step, type(xi))
      if ((fuNu = InsertScheduleRAT(DFG[i]->op, step)) != -1) {

        // S(i) = step 
        // Specificaly, update the operator's start and end time
        DFG[i]->opScheduledSlot = step;
        DFG[i]->opResultDoneSlot = step + DFG[i]->opLatency;
        DFG[i]->opResourceNu = fuNu + 1;
        myprintf("DFG node %d has resourceNu %d\n", i, fuNu);

        UpdateASAP(i, ASAP_slots, ALAP_slots, step);

        myprintf("Start enumerating at DFG node %d\n", i+1);
        Enumerate(ASAP_slots, ALAP_slots, i+1);
        myprintf("Return from enumerating at DFG node %d\n", i+1);

        DecScheduleRAT(i, step);
      }

      // restore ASAP values
      memcpy(ASAP_slots, save_ASAP_slots, NODE_NU * sizeof(int));
      memcpy(ALAP_slots, save_ALAP_slots, NODE_NU * sizeof(int));
      free(save_ASAP_slots);
      free(save_ALAP_slots);
    }
  }
}
Exemplo n.º 20
0
/*Distanceは最良一致を追求するが、こちらは与えられた条件に合致するものをすべて列挙する。アルゴリズムはほとんど一緒*/
void Enumerate(sIntMatrix2 *a,
	      sMark2 *ma,
	      sIntMatrix2 *b,
	      sMark2 *mb,
	      int sum)
{
  int i;
  int ncandidate,*candidate;
  ncandidate=Mark2_RStackSize(mb);
  candidate=malloc(sizeof(int)*ncandidate);
  for(i=0;i<Mark2_RStackSize(mb);i++){
    candidate[i]=Mark2_RStack(mb,i);
  }
  for(i=0;i<ncandidate;i++){
    int j=candidate[i];
    int k;
    int ds=0;
    int anode=Mark2_OStack(ma,Mark2_OStackSize(mb));
    if(sum>BestResult)break;
    Mark2_Occupy(mb,j);
    MarkRim(mb,b,j);
    for(k=0;k<Mark2_OStackSize(mb)-1;k++){
      int delta=weight[a->a[anode*a->n+Mark2_OStack(ma,k)]]-
	weight[b->a[j*b->n+Mark2_OStack(mb,k)]];
      ds+=delta*delta;
    }
    /*
    {
	int k;
	int x[Mark2_OStackSize(ma)];
	for(k=0;k<Mark2_OStackSize(ma);k++){
            int l=Mark2_OStack(ma,k);
            x[l]=k;
	}
	for(k=0;k<Mark2_OStackSize(mb);k++){
            printf( "(%d)%d ", Mark2_OStack(ma,k), Mark2_OStack(mb,k));
	}
	printf( " = %d\n", sum+ds );
    }
    */
    if(sum+ds<=BestResult){
      if(Mark2_OStackSize(ma)==Mark2_OStackSize(mb)){
	int k;
	int x[Mark2_OStackSize(ma)];
        
	for(k=0;k<Mark2_OStackSize(ma);k++){
	  int l=Mark2_OStack(ma,k);
	  x[l]=k;
	}
	for(k=0;k<Mark2_OStackSize(mb);k++){
            printf("%d ",Mark2_OStack(mb,x[k]));
	}
	printf("\n");
      }else{
	Enumerate(a,ma,b,mb,ds+sum);
      }
    }
    /*markの使い方を工夫する。0で空き、正で周縁、256以上は占有とする。*/
    Mark2_Unoccupy(mb,j);
    UnmarkRim(mb,b,j);
  }
  free(candidate);
}
Exemplo n.º 21
0
bool RenderCore::Init(const RenderCoreDesc& rcdesc)
{
	m_pD3D = Direct3DCreate9(D3D_SDK_VERSION);
	if(!m_pD3D)
	{
		// Push error-code into the error-pipeline
		return false;
	}

	m_RCDesc = rcdesc;

	AppMinStencilBits = m_RCDesc.HR_MinStencilBits;
	AppUsesDepthBuffer = true;
    AppUsesMixedVP = m_RCDesc.HR_UsesMixedVP;
	if(m_RCDesc.m_PresentParameters.Windowed)
	{
		AppRequiresWindowed = true;
	}
	else
	{
		AppRequiresFullscreen = true;
	}

	if(FAILED(Enumerate()))
	{
		// Push error-code into the error-pipeline
		return false;
	}
	else
	{
		if(m_AdapterInfoList.empty())
		{
			// Push error-code into the error-pipeline
			return false;
		}
	}

	unsigned int AdapterInfoID = 0xFFFFFFFF;
	unsigned int DeviceInfoID = 0xFFFFFFFF;
	unsigned int DeviceComboID = 0xFFFFFFFF;
	for(unsigned int iAdapter = 0; iAdapter < m_AdapterInfoList.size(); ++iAdapter)
	{
		D3DAdapterInfo AdapterInfo = m_AdapterInfoList[iAdapter];

		if(AdapterInfo.AdapterOrdinal == m_RCDesc.m_Adapter)
		{
			m_AdapterInfo = AdapterInfo;
			AdapterInfoID = iAdapter;

			if(FAILED(m_pD3D->GetAdapterDisplayMode(AdapterInfo.AdapterOrdinal, &m_DisplayMode)))
			{
				// Push error-code into error-pipeline
				return false;
			}

			for(unsigned int iDevice = 0; iDevice < m_AdapterInfo.DeviceInfoList.size(); ++iDevice)
			{
				D3DDeviceInfo DeviceInfo = m_AdapterInfo.DeviceInfoList[iDevice];

				if(DeviceInfo.DevType == m_RCDesc.m_DeviceType)
				{
					m_DeviceInfo = DeviceInfo;
					DeviceInfoID = iDevice;

					unsigned int NumOfDeviceCombos = m_DeviceInfo.DeviceComboList.size();

					for(unsigned int iDeviceCombo = 0; iDeviceCombo < m_DeviceInfo.DeviceComboList.size(); ++iDeviceCombo)
					{
						D3DDeviceCombo DeviceCombo = m_DeviceInfo.DeviceComboList[iDeviceCombo];

						if(m_RCDesc.m_PresentParameters.Windowed)  // 窗口模式
						{
							if(DeviceCombo.AdapterFormat == m_DisplayMode.Format)  // 此适配器的显示模式必须与桌面模式一致
							{
								if(DeviceCombo.IsWindowed == true)  // 此适配器必须支持桌面模式
								{
									m_RCDesc.m_DisplayColorBits = FormatToColorBits(DeviceCombo.BackBufferFormat);

									m_DeviceCombo = DeviceCombo;
									DeviceComboID = iDeviceCombo;
									break;
								}
							}
						}
						else  // 全屏幕,不要求适配器的显示模式与桌面模式一致
						{
							if(FormatToColorBits(DeviceCombo.BackBufferFormat) == m_RCDesc.m_DisplayColorBits && DeviceCombo.IsWindowed == false)
							{
								m_DeviceCombo = DeviceCombo;
								DeviceComboID = iDeviceCombo;

								break;
							}
						}
					}

					break;
				}
			}

			break;
		}
	}

	if(AdapterInfoID == 0xFFFFFFFF || DeviceInfoID == 0xFFFFFFFF || DeviceComboID == 0xFFFFFFFF)
	{
		// Push error-code into error-line
		return false;
	}


	if(m_RCDesc.HR_UsesMixedVP)
	{
		m_RCDesc.m_dwBehaviors = D3DCREATE_MIXED_VERTEXPROCESSING;
	}
	else
	{
		if(!GetBehavior(m_RCDesc.m_dwBehaviors, SOFTWARE_VP))
		{
			if(!GetBehavior(m_RCDesc.m_dwBehaviors, HARDWARE_VP))
			{
				if(!GetBehavior(m_RCDesc.m_dwBehaviors, PURE_HARDWARE_VP))
				{
					// Push error-code into error-pipeline
					return false;
				}
			}
		}
	}


	m_DisplayMode.Width = m_RCDesc.m_PresentParameters.BackBufferWidth;
	m_DisplayMode.Height = m_RCDesc.m_PresentParameters.BackBufferHeight;
	if(m_RCDesc.m_PresentParameters.Windowed)
	{
		D3DDISPLAYMODE DesktopMode;
		if(FAILED(m_pD3D->GetAdapterDisplayMode(m_AdapterInfo.AdapterOrdinal, &DesktopMode)))
		{
			// Push error-code into error-pipeline
			return false;
		}

		m_RCDesc.m_PresentParameters.BackBufferFormat = DesktopMode.Format;

		m_DisplayMode.Width = DesktopMode.Width;
		m_DisplayMode.Height = DesktopMode.Height;
		m_DisplayMode.Format = DesktopMode.Format;
	}
	else
	{
		m_RCDesc.m_PresentParameters.BackBufferFormat = m_DeviceCombo.BackBufferFormat;

		m_DisplayMode.Format = m_RCDesc.m_PresentParameters.BackBufferFormat;
	}

	m_RCDesc.m_PresentParameters.BackBufferCount = 0;

	vector<DSMSPair> AvailableDSMSPairs;
	for(unsigned int iDSF = 0; iDSF < m_DeviceCombo.DepthStencilFormatList.size(); ++iDSF)
	{
		D3DFORMAT dsf = m_DeviceCombo.DepthStencilFormatList[iDSF];

		for(unsigned int iMS = 0; iMS < m_DeviceCombo.MultiSampleTypeList.size(); ++iMS)
		{
			D3DMULTISAMPLE_TYPE ms = m_DeviceCombo.MultiSampleTypeList[iMS];

			bool bConflict = false;
			for(unsigned int iDSMSConflict = 0; iDSMSConflict < m_DeviceCombo.DSMSConflictList.size(); ++iDSMSConflict)
			{
				D3DDSMSConflict DSMSConflict = m_DeviceCombo.DSMSConflictList[iDSMSConflict];

				if(DSMSConflict.DSFormat == dsf && DSMSConflict.MSType == ms)
				{
					bConflict = true;
					break;
				}
			}
			if(!bConflict)
			{
				DSMSPair dsms = {dsf, iMS};
				AvailableDSMSPairs.push_back(dsms);
			}
		}
	}

	unsigned int itemp = AvailableDSMSPairs.size();
	if(AvailableDSMSPairs.empty())
	{
		// Push error-code into error-pipeline
		return false;
	}

	DSMSPair dsms = AvailableDSMSPairs[AvailableDSMSPairs.size() - 1];

	m_RCDesc.m_PresentParameters.MultiSampleType = m_DeviceCombo.MultiSampleTypeList[dsms.MSID];
	m_RCDesc.m_PresentParameters.MultiSampleQuality = m_DeviceCombo.MultiSampleQualityList[dsms.MSID] - 1;
	m_RCDesc.m_PresentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
	m_RCDesc.m_PresentParameters.EnableAutoDepthStencil = true;
	m_RCDesc.m_PresentParameters.AutoDepthStencilFormat = dsms.DSFormat;
	m_RCDesc.m_PresentParameters.Flags = 0;
	if(m_RCDesc.m_PresentParameters.Windowed)
	{
		m_RCDesc.m_PresentParameters.Flags = D3DPRESENTFLAG_DEVICECLIP;
	}


	m_RCDesc.m_PresentParameters.FullScreen_RefreshRateInHz = 0;
	if(!m_RCDesc.m_PresentParameters.Windowed)
	{
		for(unsigned int iDM = 0; iDM < m_AdapterInfo.DisplayModeList.size(); ++iDM)
		{
			D3DDISPLAYMODE dm = m_AdapterInfo.DisplayModeList[iDM];
			if(dm.Width == m_DisplayMode.Width && dm.Height == m_DisplayMode.Height && dm.Format == m_DisplayMode.Format)
			{
				if(m_RCDesc.m_PresentParameters.FullScreen_RefreshRateInHz < dm.RefreshRate)
				{
					m_RCDesc.m_PresentParameters.FullScreen_RefreshRateInHz = dm.RefreshRate;
				}
			}

		}
	}
	m_RCDesc.m_PresentParameters.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;


	//m_RCDesc.m_PresentParameters.MultiSampleQuality = 0;
	//m_RCDesc.m_PresentParameters.SwapEffect = D3DSWAPEFFECT_COPY;

	HRESULT hr = m_pD3D->CreateDevice(m_AdapterInfo.AdapterOrdinal, m_DeviceInfo.DevType, m_RCDesc.m_hWnd, m_RCDesc.m_dwBehaviors, &m_RCDesc.m_PresentParameters, &m_pD3DDevice);
	if(FAILED(hr))
	{
		// Push error-code into the error-pipeline
		throw Common::Exception(Common::EL_BAD, "RenderCore::Initiate", "Failed to create D3DDevice!");

		return false;
	}

	// Initialize The RenderState registry
	InitRSRegistry();

	return true;
}
Exemplo n.º 22
0
int main(int argc,char *argv[])
{
  int i;
  int count=0;
  sMark2 *mref;
  FILE *file;
  sIntMatrix2 *ref;
  char buf[20000];

  if((argc!=3)&&(argc!=4)){
    fprintf(stderr,"usage: %s refstruc struc [MaxDiff]\n",argv[0]);
    fprintf(stderr,"structures must be in format @DMTX or @NGPH\n");
    exit(1);
  }
  if(argc==4){
    BestResult = atoi(argv[3]);
  }else{
    /*extract the exact shape only*/
    BestResult = 0;
  }
  /*最初は参照ネットワークフラグメント*/
  int gzip = gzipopen( argv[1], &file );

  while(NULL!=fgets(buf,sizeof(buf),file)){
    if(0==strncmp(buf,"@DMTX",5)){
      ref=IntMatrix2_LoadDMTX(file);
      break;
    }
    if(0==strncmp(buf,"@NGPH",5)){
      ref=IntMatrix2_LoadNGPH(file);
      break;
    }
  }
  if ( gzip )
      pclose( file );
  else
      fclose(file);
  fprintf(stderr,"%d\tMaxDiff\n",BestResult );
  
  mref=Mark2_New(ref->n);
  Mark2_Occupy(mref,0);
  MarkRim(mref,ref,0);
  /*ref側ははじめから順番を決めておく。*/
  while(Mark2_RStackSize(mref)){
      i=Mark2_RStack(mref,0);
      Mark2_Occupy(mref,i);
      MarkRim(mref,ref,i);
  }
  gzip = gzipopen( argv[2], &file );
  while(NULL!=fgets(buf,sizeof(buf),file)){
      sIntMatrix2* big = NULL;
      if(0==strncmp(buf,"@DMTX",5))
          big = IntMatrix2_LoadDMTX(file);
      if(0==strncmp(buf,"@NGPH",5))
          big = IntMatrix2_LoadNGPH(file);
      if( big ){
          sMark2* mbig = Mark2_New(big->n);
          fprintf(stderr,"[%d]",count++);
          printf("@FRAG\n%d %d\n",ref->n,big->n);
          for(i=0;i<big->n;i++){
              Mark2_Occupy(mbig,i);
              MarkRim(mbig,big,i);
              Enumerate(ref,mref,big,mbig,0);
              Mark2_Unoccupy(mbig,i);
              UnmarkRim(mbig,big,i);
          }
          IntMatrix2_Done(big);
          Mark2_Done(mbig);
          for(i=0;i<ref->n;i++){
              printf("-1 ");
          }
          printf("\n");
      }
  }
  if ( gzip )
      pclose( file );
  else
      fclose( file );
  exit(0);
}
Exemplo n.º 23
0
/*
 * Init call
 */
ALDeviceList::ALDeviceList()
{
    m_defaultDeviceIndex		= -1;
    Enumerate();
}
Exemplo n.º 24
0
/* --------- Local Code --------- */
// static OSErr enumerate_files(
//	struct find_file_pb *param_block, 
//	long directory_id) /* Because it is recursive.. */
bool FileFinder::Enumerate(DirectorySpecifier& Dir)
{
	// Set up the temporary file
	TempFile.FromDirectory(Dir);

	// Kludge to make the FSSpec always available
	FSSpec& temp_file = TempFile.GetSpec();
	
	// Local variable
	short index;

	obj_clear(pb);
	
	pb.hFileInfo.ioVRefNum= Dir.Get_vRefNum();
	pb.hFileInfo.ioNamePtr= temp_file.name;

        // ZZZ addition
        bool KeepGoing = true;
			
	for(Err= noErr, index=1; count<max && Err==noErr && KeepGoing; index++) 
	{
		pb.hFileInfo.ioDirID= Dir.Get_parID();
		pb.hFileInfo.ioFDirIndex= index;

		Err= PBGetCatInfo( &pb, false);
		if(Err == noErr)
		{
			if ((pb.hFileInfo.ioFlAttrib & 16) && (flags & _ff_recurse))
			{
				/* Recurse, if you really want to... */

                                // ZZZ addition: callback on directory change if desired
                                if(directory_change_callback != NULL)
                                        KeepGoing = directory_change_callback(TempFile, true, (flags & _ff_callback_with_catinfo) ? &pb : user_data);

                                if(KeepGoing)
                                {
                                        // Set up volume info
                                        DirectorySpecifier SubDir = Dir;
                                        // Change the directory
                                        SubDir.Set_parID(pb.dirInfo.ioDrDirID);
                                        // Go!
                                        Enumerate(SubDir);
                                        // Reset the temporary file's directory to what's appropriate here
                                        // (it's global to this object)
                                        TempFile.FromDirectory(Dir);

                                        // ZZZ addition: callback on directory change if desired
                                        if(directory_change_callback != NULL)
                                                KeepGoing = directory_change_callback(TempFile, false, (flags & _ff_callback_with_catinfo) ? &pb : user_data);

                                }                                        
				
			} else {
				/* Add.. */
				if(Type==WILDCARD_TYPE || 
				   Type == TempFile.GetType())
				{
					/* Only add if there isn't a callback or it returns true */
					switch(search_type)
					{
						case _fill_buffer:
							if(!callback || callback(TempFile, user_data))
							{
								/* Copy it in.. */
								buffer[count++] = TempFile;
							}
							break;
							
						case _callback_only:
							assert(callback);
                                                                KeepGoing = callback(TempFile, (flags & _ff_callback_with_catinfo) ? &pb : user_data);
							break;
							
						default:
							assert(false);
							break;
					}
				}
			}
		} else {
			/* We ran out of files.. */
		}
	}

	/* If we got a fnfErr, it was because we indexed too far. */	
	if (Err == fnfErr) Err = noErr;
	
	return (Err == noErr);
}
Exemplo n.º 25
0
void
nsSupportsHashtable::Reset()
{
    Enumerate(ReleaseElement, nsnull);
    nsHashtable::Reset();
}
Exemplo n.º 26
0
HRESULT CSystemDeviceEnumerator::EnumerateVideoCaptureDevices(std::vector<CString>& vectorVidCap)
{
	return Enumerate(vectorVidCap, CLSID_VideoInputDeviceCategory);
}
Exemplo n.º 27
0
HRESULT CSystemDeviceEnumerator::EnumerateAudioCompressors(std::vector<CString>& vectorAudComp)
{
	EnumerateDMOs(DMOCATEGORY_AUDIO_ENCODER);
	return Enumerate(vectorAudComp, CLSID_AudioCompressorCategory);
}
Exemplo n.º 28
0
HRESULT CSystemDeviceEnumerator::EnumerateAudioDevices(std::vector<CString>& vectorAudDev)
{
	return Enumerate(vectorAudDev, CLSID_AudioInputDeviceCategory);
}
Exemplo n.º 29
0
HRESULT CSystemDeviceEnumerator::EnumerateVideoCompressors(std::vector<CString>& vectorVidComp)
{
	EnumerateDMOs(DMOCATEGORY_VIDEO_ENCODER);
	return Enumerate(vectorVidComp, CLSID_VideoCompressorCategory);
}
Exemplo n.º 30
0
nsSupportsHashtable::~nsSupportsHashtable()
{
    Enumerate(ReleaseElement, nsnull);
}