Пример #1
0
// returns a pointer to a node to abort walking the tree
// returns NULL to continue walking the tree
// return value is driven proc
node_t *walk_tree(node_t *pNode, node_t *(*pProc)(node_t *pNode))
{
	node_t* left = NULL;
	node_t* right = NULL;
	node_t* result = NULL;

	// pProc may be destructive
	// cache left and right
	if (NULL != pNode) {
		left = pNode->left;
		right = pNode->right;
	}

	// walk left if possible and not done
	if (NULL != left && NULL == result) {
		result = walk_tree(left, pProc);
	}

	// proc current node if possible and not done
	if (NULL != pProc && NULL == result) {
		result = pProc(pNode);
	}

	// walk right if possible and not done
	if (NULL != right && NULL == result) {
		result = walk_tree(right, pProc);
	}

	return result;
}
Пример #2
0
int CpaneFixWave::GetSample( int nSecond, double * & pBuffer, int nSampleRate, int nBps )
{
	typedef double (*pWaveProc)(double theta, int bps);

	pWaveProc pProc;

	static pWaveProc arrProc[4] = 
	{
		senoide,
		quadrada,
		triangular,
		dente_serra
	};

	double nFreq = (double)GetDlgItemInt(IDC_ED_FREQ);

	for(int i = 0; i < nSampleRate; i++)
	{
		double tetha = (i*2.0*M_PI*nFreq)/(double)nSampleRate;

		double & sample = pBuffer[i];

		pProc = arrProc[m_nWaveType];

		sample = pProc(tetha, nBps);

	}
	return 0;
}
Пример #3
0
// not robust enough to perform a delete
node_t *find_node(node_t *pNode, node_t *(*pProc)(node_t *pNode, const char *pValue), const char *pValue)
{
	// proc null root
	if (NULL == pNode) {
		return pProc(pNode, pValue);
	}

	int compare = strcmp(pValue, pNode->value);

	// proc this node
	if (0 == compare) {
		return pProc(pNode, pValue);
	}

	// if less than current value, left
	else if (compare < 0) {
		// if null the value would go here, proc and set
		if (NULL == pNode->left) {
			return pNode->left = pProc(pNode->left, pValue);
		// otherwise keep searching
		} else {
			return find_node(pNode->left, pProc, pValue);
		}
	}

	// if greater than current value, right
	else if (0 < compare) {
		// if null the value would go here, proc and set
		if (NULL == pNode->right) {
			return pNode->right = pProc(pNode->right, pValue);
		// otherwise keep searching
		} else {
			return find_node(pNode->right, pProc, pValue);
		}
	}

	// not a match
	return NULL;
}
Пример #4
0
//==============================================================
//==============================================================
IGridUser* CreateGridUserObject(DWORD version)
{
 static HINSTANCE DLLHandle(0);
 
 if (DLLHandle==0)
  {
   DLLHandle = LoadLibrary("hxGridUserDLL.dll");
   assert(DLLHandle!=0);
  } 
  
 static TCreateGridUserObject* pProc(NULL); 

 if (pProc==NULL)
  {
   pProc = (TCreateGridUserObject*)GetProcAddress(DLLHandle,"CreateGridUserObject");
   assert(pProc!=NULL);
  }
 return pProc(version); 
}
Пример #5
0
//==============================================================
//==============================================================
IGenericStream* CreateGenericStream()
{
 static HINSTANCE DLLHandle(0);
 
 if (DLLHandle==0)
  {
   DLLHandle = LoadLibrary("hxGridUserDLL.dll");
   assert(DLLHandle!=0);
  } 
  
 static TCreateGenericStream* pProc(NULL); 

 if (pProc==NULL)
  {
   pProc = (TCreateGenericStream*)GetProcAddress(DLLHandle,"CreateGenericStream");
   assert(pProc!=NULL);
  }
 return pProc(); 
}
Пример #6
0
Burger::LinkedListObjects::Object *Burger::LinkedListObjects::IterateForward(ProcAction pProc)
{
	Object *pFirst = m_pRoot;		// Is there a list?
	if (pFirst) {
		Object *pObject = pFirst;
		do {
			Word uResult = pProc(pObject->GetData());	// Call the function
			Object *pNext = pObject->GetNext();			// Get the next entry
			if (uResult&DELETEOBJECT) {					// Dispose of the entry?
				DestroyObject(pObject);
			}
			if (uResult&ABORT) {		// Abort the traversal?
				pFirst = pObject;
				break;
			}
			pObject = pNext;			// Next entry please...
		} while (pObject!=pFirst);		// More left?
	}
	return pFirst;						// Entry I stopped on
}
Пример #7
0
 static pProc Create() {
     return pProc(new If());
 }
boost::shared_ptr<ConsoleProcessInfo> ConsoleProcessInfo::fromJson(core::json::Object& obj)
{
   boost::shared_ptr<ConsoleProcessInfo> pProc(new ConsoleProcessInfo());

   json::Value handle = obj["handle"];
   if (!handle.is_null())
      pProc->handle_ = handle.get_str();
   json::Value caption = obj["caption"];
   if (!caption.is_null())
      pProc->caption_ = caption.get_str();

   json::Value showOnOutput = obj["show_on_output"];
   if (!showOnOutput.is_null())
      pProc->showOnOutput_ = showOnOutput.get_bool();
   else
      pProc->showOnOutput_ = false;

   json::Value mode = obj["interaction_mode"];
   if (!mode.is_null())
      pProc->interactionMode_ = static_cast<InteractionMode>(mode.get_int());
   else
      pProc->interactionMode_ = InteractionNever;

   json::Value maxLines = obj["max_output_lines"];
   if (!maxLines.is_null())
      pProc->maxOutputLines_ = maxLines.get_int();
   else
      pProc->maxOutputLines_ = kDefaultMaxOutputLines;

   json::Value bufferedOutputValue = obj["buffered_output"];
   if (!bufferedOutputValue.is_null())
   {
      std::string bufferedOutput = bufferedOutputValue.get_str();
      std::copy(bufferedOutput.begin(), bufferedOutput.end(),
                std::back_inserter(pProc->outputBuffer_));
   }
   json::Value exitCode = obj["exit_code"];
   if (exitCode.is_null())
      pProc->exitCode_.reset();
   else
      pProc->exitCode_.reset(exitCode.get_int());

   pProc->terminalSequence_ = obj["terminal_sequence"].get_int();
   pProc->allowRestart_ = obj["allow_restart"].get_bool();

   json::Value title = obj["title"];
   if (!title.is_null())
      pProc->title_ = title.get_str();

   pProc->childProcs_ = obj["child_procs"].get_bool();
   int shellTypeInt = obj["shell_type"].get_int();
   pProc->shellType_ =
      static_cast<TerminalShell::TerminalShellType>(shellTypeInt);
   int channelModeInt = obj["channel_mode"].get_int();
   pProc->channelMode_ = static_cast<ChannelMode>(channelModeInt);

   json::Value channelId = obj["channel_id"];
   if (!channelId.is_null())
      pProc->channelId_ = channelId.get_str();

   pProc->altBufferActive_ = obj["alt_buffer"].get_bool();

   json::Value cwdValue = obj["cwd"];
   if (!cwdValue.is_null())
   {
      std::string cwd = cwdValue.get_str();
      if (!cwd.empty())
         pProc->cwd_ = module_context::resolveAliasedPath(obj["cwd"].get_str());
   }

   pProc->cols_ = obj["cols"].get_int();
   pProc->rows_ = obj["rows"].get_int();

   pProc->restarted_ = obj["restarted"].get_bool();
   int autoCloseInt = obj["autoclose"].get_int();
   pProc->autoClose_ = static_cast<AutoCloseMode>(autoCloseInt);
   pProc->zombie_ = obj["zombie"].get_bool();
   pProc->trackEnv_ = obj["track_env"].get_bool();

   return pProc;
}
Пример #9
0
void MainDialog::on_processImage_released()
{
    ProcessDialog pProc(this);
    pProc.init();
    ui->processImage->setPixmap(QPixmap(SystemBase::path + QString("/../resource/main/process_up.jpg")));
}