Ejemplo n.º 1
0
void TrackPropDlg::SetTrackAndUpdate( Route *pR )
{
    m_pRoute = pR;

    m_lcPoints->DeleteAllItems();
    
    if( m_pMyLinkList )
        delete m_pMyLinkList;
    m_pMyLinkList = new HyperlinkList();
    int NbrOfLinks = m_pRoute->m_HyperlinkList->GetCount();
    if( NbrOfLinks > 0 ) {
        wxHyperlinkListNode *linknode = m_pRoute->m_HyperlinkList->GetFirst();
        while( linknode ) {
            Hyperlink *link = linknode->GetData();

            Hyperlink* h = new Hyperlink();
            h->DescrText = link->DescrText;
            h->Link = link->Link;
            h->LType = link->LType;

            m_pMyLinkList->Append( h );

            linknode = linknode->GetNext();
        }
    }

    InitializeList();
    UpdateProperties();
}
Ejemplo n.º 2
0
bool GenotypeList::EliminateGenotypes(Pedigree & ped, Family * family, int marker)
{
    // First, allocate a genotype list for the family
    GenotypeList * list = new GenotypeList [family->count];

    // Next, update the possible allele lists for each individual
    InitializeList(list, ped, family, marker);

    // Then, do multiple rounds of elimination until a problem is found
    // or no changes are made

#ifdef DEBUG_ELIMINATOR
    Print(list, ped, family, marker);
#endif

    while (PairwiseCheck(list, ped, family) || FamilyCheck(list, ped, family))
#ifdef DEBUG_ELIMINATOR
        Print(list, ped, family, marker)
#endif
        ;

    for (int i = 0; i < family->count; i++)
        if (!list[i].ignore && list[i].allele1.Length() == 0)
        {
            printf("%s - Family %s has a subtle genotype inconsistency\n",
                   (const char *) ped.markerNames[marker], (const char *) family->famid);

            delete [] list;
            return false;
        }

    delete [] list;
    return true;
}
Ejemplo n.º 3
0
BOOL COpenSubDlg::OnInitDialog()
  {
   CDialog::OnInitDialog();
   // Add "About..." menu item to system menu.

   // IDM_ABOUTBOX must be in the system command range.
   ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
   ASSERT(IDM_ABOUTBOX < 0xF000);

   CMenu* pSysMenu = GetSystemMenu(FALSE);
   if (pSysMenu != NULL)
   {
      BOOL bNameValid;
      CString strAboutMenu;
      bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
      ASSERT(bNameValid);
      if (!strAboutMenu.IsEmpty())
      {
         pSysMenu->AppendMenu(MF_SEPARATOR);
         pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
      }
   }
   // Set the icon for this dialog.  The framework does this automatically
   //  when the application's main window is not a dialog
   SetIcon(m_hIcon, TRUE);         // Set big icon
   SetIcon(m_hIcon, FALSE);      // Set small icon
//--- set dialog title
   std::wstring path(theApp.m_lpCmdLine);
   SetWindowText(path.substr(path.rfind(L'\\') + 1).c_str());
//--- create list columns
   InitializeList();
   EnableButtons(FALSE);
   PrintMessage(GetSafeHwnd(), L"Searching");
   return(TRUE);
  }
Ejemplo n.º 4
0
bool TemplateCity::Initialize(){
	m_running = false;
	if (m_running == false){
		InitializeList();
		InitializeBinaryTree();
	}
	m_running = true;
	return true;
}
Ejemplo n.º 5
0
/*
 *
 *  Function: RoundRobin
 *
 *  Purpose: 	Implements the Round Robin algorithm for dipatching and
 *				then prints the Average Waiting Time (AWS) of the processess
 *				in the list
 *      
 *  Parameters:
 *            input    	A pointer to the start of the list and the quantum of
 *						which is intented to use
 *
 *            output   	Prints the average waiting time for the process list
 *
 */
void RoundRobin(GList *processList, int quantum){
	int acumulatedTime = 0;
	float timeSummation = 0;
	float numberProcess = 0;
	float average;
	GList *list = g_list_copy(processList),*i,*j;
	InitializeList(list);
	process *temp = list->data, *tempNext;
	acumulatedTime = temp->arrival_time;
	int reins;
	for (i= list; i != NULL; i=i->next) {
		temp = i->data;
		if (temp->timeleft > 0){ // Is the process finished?
			if (temp->timeleft > quantum) { // Is the process going to finish before the quantum expires?
				reins =0;
				temp->timeleft = temp->timeleft - quantum;
				acumulatedTime = acumulatedTime + quantum;

				// This section checks where the process should be reinserted (In case not all the process have arrived)
				for (j=i; j !=NULL; j = j->next) {
					tempNext= j->data;
					if ((tempNext->arrival_time > acumulatedTime)&& (reins==0) ) {
						i = g_list_insert_before(i,j->prev,temp);
						reins++;
						break;
					}
				}
				if (reins==0) {
					i = g_list_append(i,temp);
				}
				// End of section
			}
			else { // Calculates the operations to obtain the data for the formula
				temp->last_runned = acumulatedTime;
				timeSummation = timeSummation + (temp->last_runned - temp->arrival_time  - (temp->cpu_burst - temp->timeleft));
				#ifdef DEBUG
					PrintProcess(temp, acumulatedTime);
				#endif
				acumulatedTime = acumulatedTime + temp->timeleft;
				temp->timeleft = 0;
				numberProcess++;
			}
		}
	}
	average = timeSummation/numberProcess;

	// Destroy the copy of the original list and the iterators
	g_list_free(list); 
	g_list_free(i); 
	g_list_free(j);

	printf("\nRound Robin\n");
	printf("Average time = %2f\n",average);
	#ifdef DEBUG
		printf("%f %f\n",timeSummation,numberProcess);
	#endif
}
void ItemBaseManager::Initialize()
{
    ItemBaseParser m_Parser;
	m_Parser.LoadItemBase(m_ItemDB);

    InitializeHash();
    InitializeList();
	SetRefineInfo();
}
Ejemplo n.º 7
0
int main(void) {
	List movies;
	Item temp;
	
	InitializeList(&movies);
	if(ListIsFull(&movies){
		fprintf(stderr, "No memory available! Bye!\n");
		exit(1);
	}
}
Ejemplo n.º 8
0
int main(void)
{
	List movies;
	Item temp;

	/* initialize */
	InitializeList(&movies);

	if (ListIsFull(&movies))
	{
		fprintf(stderr,"No memory available! Bye!\n");
		exit(1);
	}

	/* gather and store */
	puts("Enter first movie title:");
	while (get(temp.title, TSIZE) != NULL && temp.title[0] != '\0')
	{
		puts("Enter your rating <0-10>:");
		scanf("%d", &temp.rating);
		while(getchar() != '\n')
			continue;
		
		if (AddItem(temp, &movies)==false) 
		{
			fprintf(stderr,"Problem allocating memory\n");
			break;
		}

		if (ListIsFull(&movies))
		{
			puts("The list is now full.");
			break;
		}

		puts("Enter next movie title (empty line to stop):"); 
	}
	
	/* display */
	if (ListIsEmpty(&movies))
		printf("No data entered. ");
	else
	{
		printf ("Here is the movie list:\n");
		Traverse(&movies, showmovies);
	}

	printf("You entered %d movies.\n", ListItemCount(&movies));

	/* clean up */
	EmptyTheList(&movies);

	printf("Bye!\n");
	return 0;
}
Ejemplo n.º 9
0
int main(void)
{
	List movies;
	Item temp;
	
	/* Initialize */
	InitializeList(&movies);
	if(ListIsFull(&movies))
		{
			fprintf(stderr,"No memory avaliable! Bye!\n");
			exit(1);
		}
	
	/* collecte and storage data */
	puts("Enter first movie title :");
	while(gets(temp.title) != NULL &&
				temp.title[0] != '\0')
	{
		puts("Enter your rating <0-10> : ");
		scanf("%d",&temp.rating);
		while(getchar() != '\n');
		
		if(AddItem(temp,&movies) == false)
			{
				fprintf(stderr,"Problem allocating memory\n");
				break;
			}
		if(ListIsFull(&movies))
		{
			puts("The list id full.");
			break;
		}
		
		puts("Enter next movie title (empty line to quit):");
	}
	
	/* Display List */
	if(ListIsEmpty(&movies))
		printf("No data entred.");
	else
		{
			printf("Here is the movie list :\n");
			Traverse(&movies,showmovies);			
		}
	printf("Your entered %d movies.\n",ListItemCount(&movies));
	
	/* clean list */
	EmptyTheList(&movies);
	
	printf("Bye!\n");	
	
	return 0;
}
Ejemplo n.º 10
0
void PathProp::SetPathAndUpdate( Path *pB, bool only_points )
{
    if( NULL == pB )
        return;

    //  Fetch any config file values
    if ( !only_points )
    {
        //      long LMT_Offset = 0;                    // offset in seconds from UTC for given location (-1 hr / 15 deg W)
        m_tz_selection = 1;

        if( m_pPath ) {
            m_pPath->m_iBlink--;
            if(m_pPath->m_iBlink < 0 ) 
                m_pPath->m_iBlink = 0;
        }
        m_pPath = pB;
        m_pPath->m_iBlink++;
        if(m_pPath->m_iBlink > 2) m_pPath->m_iBlink = 2;
        
        m_PathNameCtl->SetValue( m_pPath->m_PathNameString );

        m_PathNameCtl->SetFocus();
    }
    m_opList->DeleteAllItems();

#if 0
    // Select the proper list control, and add it to List sizer
    m_pListSizer->Clear();

    if( m_pPath ) {
        m_opList->Show();
        m_pListSizer->Add( m_opList, 2, wxEXPAND | wxALL, 5 );
    }
//    GetSizer()->Fit( this );
    GetSizer()->Layout();
#endif


    InitializeList();

    UpdateProperties( pB );

    if( m_pPath )
        m_opList->Show();

//    GetSizer()->Fit( this );
//    GetSizer()->Layout();

    Refresh( false );

}
Ejemplo n.º 11
0
GLFitManager::GLFitManager()
    :
    JPrefObject(GetPrefsMgr(), kFitManagerID),
    itsIsInitialized(kJFalse)
{
    itsFitDescriptions	= new JPtrArray<GLFitDescription>(JPtrArrayT::kDeleteAll);
    assert(itsFitDescriptions != NULL);

    itsFitDescriptions->SetCompareFunction(GLFitDescription::CompareFits);

    JPrefObject::ReadPrefs();

    InitializeList();
}
Ejemplo n.º 12
0
Archivo: pe17-3.cpp Proyecto: jnksu/CPP
int main(int argc, char ** argv)
{
	List movies;
	Item temp;

	/* 初始化 */
	InitializeList(&movies);
	if (ListIsFull(&movies)){
		fprintf(stderr, "No memory available! Bye!\n");
		exit(EXIT_FAILURE);
	}
	/* 收集并存储 */
	fputs("Enter first movie title: \n", stdout);
	while (fgets(temp.title, TSIZE, stdin) != NULL && temp.title[0] != '\n'){
		reject_ch(temp.title, '\n');

		fputs("Enter your rating<0-10>: \n", stdout);
		scanf_s("%d", &temp.rating);
		while (getchar() != '\n'){
			continue;
		}

		if (false == AddItem(&temp, &movies)){
			fprintf(stderr, "Problem allocating memory\n");
			exit(EXIT_FAILURE);
		}

		if (ListIsFull(&movies)){
			fputs("The list is now full.\n", stdout);
			break;
		}
		fputs("Enter next movie title(empty line to stop): \n", stdout);
	}

	/* 显示 */
	if (ListIsEmpty(&movies))
		printf("No data entered.");
	else{
		printf("Here is the movie list: \n");
		Traverse(&movies, showMovies);
	}
	printf("You entered %d movies.\n", ListItemCount(&movies));

	/* 清除 */
	EmptyTheList(&movies);
	printf("Bye!\n");

	_CrtDumpMemoryLeaks();
	return EXIT_SUCCESS;
}
Ejemplo n.º 13
0
int main(void)
{
    List list;
    InitializeList(&list); // test Initialize

    if(ListIsEmpty(&list)) //test ListIsEmpty
        printf("the list is empty\n");
    else
        printf("the list is not empty\n");
    
//    unsigned int counter=0;
//    counter=ListItemCount(&list);

    Node* pnode;

    pnode=(Node*)malloc(sizeof(Node));
    
    Item *pitem;

    pitem=(Item*)malloc(sizeof(Item));

    pitem->ID=001;
    strcpy(pitem->content, "hello list");
    pitem->value=1;
    
    pnode->item=*pitem;

    list=pnode;

    list=AddNew(list);    //test AddNew

    unsigned int counter=0;
    counter=ListItemCount(&list);
    printf("there are %u items in the list\n", counter);
    
//    void (*pfun)(Item item)=showitem;

    Traverse(&list,showitem);    //test Traverse
    
//    EmptyTheList(&list);d
    if(ListIsEmpty(&list))
        printf("list is empty!\n");
    else 
        printf("list is not empty!\n");

    EmptyTheList(&list);

    return 0;
}
Ejemplo n.º 14
0
int main(void)
{
	List movies;
	Item temp;

	/*初始化*/
	InitializeList(&movies);
	if(ListIsFull(&movies))
	{
		fprintf(stderr,"no memory available!\n");
		exit(1);
	}

	/*收集并存储*/
	puts("enter first movie title");
	while(fgets(temp.title,TSIZE,stdin) != NULL && temp.title[0] != '\n')
	{
		puts("enter your rating <0-10>:");
		scanf("%d",&temp.rating);
		while(getchar() != '\n')
			continue;
		if(AddItem(temp,&movies) == false)
		{
			fprintf(stderr,"problem allocating memory\n");
			break;
		}
		if(ListIsFull(&movies))
		{
			puts("the list is now full.");
			break;
		}
		puts("enter next movie title(empty line to stop)");
	}
		if( ListIsEmpty(&movies) )
			printf("no data entered.");
		else
		{
			printf("here is the movie list:\n");
			Traverse(&movies,showmovies);
		}
		printf("your entered %d movies.\n",ListItemCount(&movies) );
		/*清除*/
		EmptyTheList(&movies);
		printf("bye!\n");
		return 0;
			}
Ejemplo n.º 15
0
int main()
{
    List movies;
    Item temp;

    InitializeList(&movies);
    if(ListIsFull(&movies))
    {
        fprintf(stderr,"no memory available!\nBye!\n");
        exit(1);
    }

    puts("enter first movie title:");
    while(gets(temp.title) != NULL && temp.title[0] != '\0')
    {
        puts("enter your rating:");
        scanf("%d",&temp.rating);
        while(getchar() != '\n')
            continue;
        if(AddItem(temp,&movies) == false)
        {
            fprintf(stderr,"Problem allocating memory\n");
            break;
        }
        if(ListIsFull(&movies))
        {
            puts("the list is full");
            break;
        }
        puts("enter next movie title:");
    }

    if(ListIsEmpty(&movies))
    {
        printf("no data entered.");
    }
    else
    {
        printf("here is the movie list:\n");
        Traverse(&movies,ShowMovies);
    }
    printf("you entered %d movies.\n",ListItemCount(&movies));
    EmptyTheList(&movies);
    printf("Bye!\n");
    return 0;
}
Ejemplo n.º 16
0
int main(void){
	List movies;
	Item temp;
	
	//初始化 
	InitializeList(&movies);
	if(ListIsFull(&movies)){
		fprintf(stderr,"No memory available!");
		exit(1);
	}
	
	//收集并储存 
	puts("Enter first movie title:");
	while(gets(temp.title ) != NULL && temp.title [0] != '\0' ){
		puts("Enter your rating <0-10>:");
		scanf("%d",&temp.rating );
		while(getchar()!='\n'){
			continue;
		}
		if(AddItem(temp,&movies)==false){
			fprintf(stderr,"Problem allocating memory\n");
			break;
		}
		if(ListIsFull(&movies)){
			puts("The list is full.");
			break; 
		}
		puts("Enter next movie title(empty line to stop))");
	}
	
	//显示 
	if(ListIsEmpty(&movies)){
		printf("No data entered.");
	}
	else{
		printf("Here is the movie list:\n");
		Traverse(&movies,showmovies);
	}
	
	//清除 
	EmptyTheList(&movies);
	printf("Bye!");
	return 0;	
}
Ejemplo n.º 17
0
DialogPilots::DialogPilots(QWidget *pParent)
 : AbstractNesisDialog(pParent)
{
	m_bMoveToTop = true;
	const QFont& fontSm = GraphicsSingleton::GetInstance()->GetFont(GraphicsSingleton::fDialogSmall);

	// Main layout
	QVBoxLayout* pPilotLayout = new QVBoxLayout;
	setLayout(pPilotLayout);

	// List of pilots:
	QFrame* pFrame = new QFrame();
	pFrame->setFrameShape(QFrame::StyledPanel);
	pPilotLayout->addWidget(pFrame);

	// LIST layout
	QVBoxLayout* pListLayout = new QVBoxLayout;
	pFrame->setLayout(pListLayout);
	
	QLabel* pLbl = new QLabel(tr("Pilots"));
	pLbl->setFont(fontSm);
	pListLayout->addWidget(pLbl);
	
	QStringList slEditCmd;
	slEditCmd << tr("New");
	slEditCmd << tr("Edit");
	slEditCmd << tr("Delete");
	slEditCmd << QString();
	slEditCmd << tr("Close");
	
	m_plwPilots = new NesisListWidget(true /*edit mode only*/);
	m_plwPilots->SetExternalButtonLabels(slEditCmd);
	m_plwPilots->setFont(fontSm);

	m_plwPilots->setSortingEnabled(true);
	pListLayout->addWidget(m_plwPilots);

	// Currently selected pilot:
	pFrame = new QFrame();
	pFrame->setFrameShape(QFrame::StyledPanel);
	pPilotLayout->addWidget(pFrame);

	// current layout
	QVBoxLayout* pCurrentLayout = new QVBoxLayout;
	pFrame->setLayout(pCurrentLayout);
	
	pLbl = new QLabel(tr("Active pilot"));
	pLbl->setFont(fontSm);
	pCurrentLayout->addWidget(pLbl);
	m_pleSelected = new QLineEdit;
	m_pleSelected->setReadOnly(true);
	m_pleSelected->setFocusPolicy(Qt::NoFocus);
	m_pleSelected->setFont(fontSm);
	pCurrentLayout->addWidget(m_pleSelected);
	
	// External commands
	QStringList slExternalCmd;
	slExternalCmd << QString();
	slExternalCmd << QString();
	slExternalCmd << QString();
	slExternalCmd << QString();
	slExternalCmd << tr("Close");

	connect(m_plwPilots, SIGNAL(NesisOk()), this, SLOT(OnPilotSelect()));
	connect(m_plwPilots, SIGNAL(NesisButton(int)), this, SLOT(OnNesisEditList(int)));
	connect(m_plwPilots, SIGNAL(NesisButton(int)), this, SLOT(OnExternalCmd(int)));

	InitializeList();
	Activate();
}
Ejemplo n.º 18
0
std::list<std::string> AndroidMediaSource::getFolderBlacklist() const
{
    LOG4CPLUS_TRACE_METHOD(mLogger, __PRETTY_FUNCTION__);
    static std::list<std::string> blacklist = InitializeList();
    return blacklist;
}
Ejemplo n.º 19
0
/////////////////////////////////////////////////////////////////////////////
// CAccessDialog message handlers
BOOL CAccessDialog::OnInitDialog()
{
	CDialog::OnInitDialog();

	m_SMegabytes.SetRange(0, MAX_SIZE_RANGE);
	m_SKilobytes.SetRange(0, MAX_SIZE_RANGE);
	m_SBytes.SetRange(0, MAX_SIZE_RANGE);
	m_SAlignMegabytes.SetRange(0, MAX_SIZE_RANGE);
	m_SAlignKilobytes.SetRange(0, MAX_SIZE_RANGE);
	m_SAlignBytes.SetRange(0, MAX_SIZE_RANGE);
	m_SAlignBytes.SetPos(512);
	m_SReplyMegabytes.SetRange(0, MAX_SIZE_RANGE);
	m_SReplyKilobytes.SetRange(0, MAX_SIZE_RANGE);
	m_SReplyBytes.SetRange(0, MAX_SIZE_RANGE);

	m_SAccess.SetRange(1, 100);
	m_SAccess.SetPageSize(10);
	m_SRead.SetRange(0, 100);
	m_SRead.SetPageSize(10);
	m_SRandom.SetRange(0, 100);
	m_SRandom.SetPageSize(10);

	size_controls.EBytesCtrl = &m_EBytes;
	size_controls.EKilobytesCtrl = &m_EKilobytes;
	size_controls.EMegabytesCtrl = &m_EMegabytes;
	size_controls.EBytesID = EBytes;
	size_controls.EKilobytesID = EKilobytes;
	size_controls.EMegabytesID = EMegabytes;
	size_controls.SBytesCtrl = &m_SBytes;
	size_controls.SKilobytesCtrl = &m_SKilobytes;
	size_controls.SMegabytesCtrl = &m_SMegabytes;
	size_controls.SBytesID = SBytes;
	size_controls.SKilobytesID = SKilobytes;
	size_controls.SMegabytesID = SMegabytes;
	size_controls.RSelectedID = 0;
	size_controls.RNotSelectedID = 0;

	// 2462 SDK compiler didn't like the "this->" for Win64 so we'll just remove it
	//  since it really isn't needed anyway...
	//size_controls.GetFunc                 = this->GetSize;
	//size_controls.SetFunc                 = this->SetSize;
	size_controls.GetFunc = GetSize;
	size_controls.SetFunc = SetSize;

	align_controls.EBytesCtrl = &m_EAlignBytes;
	align_controls.EKilobytesCtrl = &m_EAlignKilobytes;
	align_controls.EMegabytesCtrl = &m_EAlignMegabytes;
	align_controls.EBytesID = EAlignBytes;
	align_controls.EKilobytesID = EAlignKilobytes;
	align_controls.EMegabytesID = EAlignMegabytes;
	align_controls.SBytesCtrl = &m_SAlignBytes;
	align_controls.SKilobytesCtrl = &m_SAlignKilobytes;
	align_controls.SMegabytesCtrl = &m_SAlignMegabytes;
	align_controls.SBytesID = SAlignBytes;
	align_controls.SKilobytesID = SAlignKilobytes;
	align_controls.SMegabytesID = SAlignMegabytes;
	align_controls.RSelectedID = RAlignBytes;
	align_controls.RNotSelectedID = RAlignSector;

	// 2462 SDK compiler didn't like the "this->" for Win64 so we'll just remove it
	//  since it really isn't needed anyway...
	//align_controls.GetFunc                        = this->GetAlign;
	//align_controls.SetFunc                        = this->SetAlign;
	align_controls.GetFunc = GetAlign;
	align_controls.SetFunc = SetAlign;

// RSelectedID MUST be greater than RNotSelectedID, for the sake of GetCheckedRadioButton().
#if !(RAlignBytes > RAlignSector)
#error RAlignBytes is not greater than RAlignSector in resource.h!
#endif

	reply_controls.EBytesCtrl = &m_EReplyBytes;
	reply_controls.EKilobytesCtrl = &m_EReplyKilobytes;
	reply_controls.EMegabytesCtrl = &m_EReplyMegabytes;
	reply_controls.EBytesID = EReplyBytes;
	reply_controls.EKilobytesID = EReplyKilobytes;
	reply_controls.EMegabytesID = EReplyMegabytes;
	reply_controls.SBytesCtrl = &m_SReplyBytes;
	reply_controls.SKilobytesCtrl = &m_SReplyKilobytes;
	reply_controls.SMegabytesCtrl = &m_SReplyMegabytes;
	reply_controls.SBytesID = SReplyBytes;
	reply_controls.SKilobytesID = SReplyKilobytes;
	reply_controls.SMegabytesID = SReplyMegabytes;
	reply_controls.RSelectedID = RReplySize;
	reply_controls.RNotSelectedID = RNoReply;

	// 2462 SDK compiler didn't like the "this->" for Win64 so we'll just remove it
	//  since it really isn't needed anyway...
	//reply_controls.GetFunc                        = this->GetReply;
	//reply_controls.SetFunc                        = this->SetReply;
	reply_controls.GetFunc = GetReply;
	reply_controls.SetFunc = SetReply;

// RSelectedID MUST be greater than RNotSelectedID, for the sake of GetCheckedRadioButton().
#if !(RReplySize > RNoReply)
#error RReplySize is not greater than RNoReply in resource.h!
#endif

	UpdateData(FALSE);

	// Initialize the listbox object.
	InitializeList();

	// Get listbox display data from AccessSpecList.
	LoadList();

	// If there are any entries in the list, highlight the first one.
	if (m_LAccess.GetItemCount()) {
		item_being_changed = 0;
		m_LAccess.SetItemState(m_LAccess.GetItemCount() - 1, !LVIS_SELECTED, LVIS_SELECTED);
		m_LAccess.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
		SetAll((Access_Spec *) m_LAccess.GetItemData(0));
	}

	UpdateData(TRUE);

	return TRUE;		// return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
Ejemplo n.º 20
0
/*
 *
 *  Function: Preemptive
 *
 *  Purpose: 	Implements the preemptive algorithm for dispatching and
 *				then prints the Average Waiting Time (AWS) of the processess
 *				in the list
 *      
 *  Parameters:
 *            input    	A pointer to the start of the list and the parameter
 *						which it will use to apply the algorithm
 *
 *            output   	Prints the average waiting time for the process list
 *
 */
void Preemptive(GList *processList,  enum OPTION param) {
	int acumulatedTime = 0;
	float timeSummation = 0;
	float numberProcess = 0;
	float average;
	GList *arr; // List of arrivals
	GList *i = NULL; // Running list
	process *temp, *tempNext;
	
	arr = g_list_copy(processList);
	InitializeList(arr);
	do{
		if (arr!=NULL) { //Is a process spected to arrive?
			temp = arr->data;
			if (i==NULL) {
				acumulatedTime = temp->arrival_time;
			}
			i = g_list_append(i,temp); // Add the process and then order the running list
			
			if (param == 1)
				i = SortProcessList(i,3);
			else
				i = SortProcessList(i,param);

			arr = arr->next; // Advance the list of arrivals to the next item
		}
		if (arr!=NULL) { // Is a process spected to arrive next?
			temp = i->data; // For modify current item
			tempNext = arr->data; // To check when does the new process arrives
			if (temp->timeleft > 0){ // Is this process finished?
				if (temp->timeleft > (tempNext->arrival_time - acumulatedTime )) { // Will the actual process finish before the next process arrives?
					temp->timeleft =temp->timeleft  - (tempNext->arrival_time - acumulatedTime); // If not finish before the new arrival, reduce the time still have to run
					acumulatedTime = acumulatedTime + (tempNext->arrival_time - acumulatedTime); // Aument the acumulated time
					i = g_list_append(i,temp); //append the process to be runned again
				}
				else { // If finishes before the new arrival 
					temp->last_runned = acumulatedTime; // Last time the process runned
					timeSummation = timeSummation + (temp->last_runned - temp->arrival_time  - (temp->cpu_burst - temp->timeleft)); //Add to the counter of the formula
					#ifdef DEBUG
						PrintProcess(temp, acumulatedTime);
					#endif
					acumulatedTime = acumulatedTime + temp->timeleft; // Aument the acumulated time
					temp->timeleft = 0; // Finish the process
					numberProcess++; // Aument the number of processess
				}
			}
		}
		else{ // No more arrivals are expected
			temp = i->data; // To transform the current item
			if (temp->timeleft > 0){ // Is this process finished?
				temp->last_runned = acumulatedTime; // Last time the process runned
				timeSummation = timeSummation + (temp->last_runned - temp->arrival_time  - (temp->cpu_burst - temp->timeleft));
				#ifdef DEBUG
					PrintProcess(temp, acumulatedTime);
				#endif
				acumulatedTime = acumulatedTime + temp->timeleft; //Aument the acumulated time
				temp->timeleft = 0; //Finish the process
				numberProcess++; // Aument the numer of processess
			}
		}
		i = i->next; // Go to the next process in the list

	}while(i!=NULL || arr!= NULL); // Do it until the list is finished
	
	average = timeSummation/numberProcess;  // Calculate the average
	g_list_free(arr); // Destroy the copy of the original list
	g_list_free(i);
	if (param==1) {
		printf("\nPreemptive cpu_burst\n");
	}
	else if (param==2) {
		printf("\nPreemptive priority\n");
	}
	printf("Average time = %2f\n",average);
	#ifdef DEBUG
		printf("%f %f\n",timeSummation,numberProcess);
	#endif
}
Ejemplo n.º 21
0
int wmain( int argc, LPTSTR argv[] )
{
    // Vars declarations
    int targetDirInd = 0;
    BOOL flags[ MAX_OPTIONS ] = { 0 };
    TCHAR workDir[ MAX_PATH ] = { 0 };
    TCHAR targetDir[ MAX_PATH ] = { 0 };
    DWORD workLength = 0;
    List resultsList = { 0 };
    Item resultsItem = { 0 };
    PVOID oldValueWow64 = NULL;
    BOOL wow64Disabled = FALSE;
    TCHAR* ptTchar = NULL;

    // Get index of first argument after options
    // Also determine which options are active
    targetDirInd = Options( argc, argv, TEXT( "h" ), &flags[ FL_HELP ], NULL );
    
    // Get current working dir
    workLength = GetCurrentDirectory( _countof( workDir ), workDir );

    // Validate target dir
    if ( ( argc > targetDirInd + 1 ) || flags[ FL_HELP ] )
    {
        // More than one target or
        // target with gaps (no quotes) specified or
        // asked for help

        // Print usage
        wprintf_s( TEXT( "\n    Usage:    jdots [options] [target dir]\n\n" ) );
        wprintf_s( TEXT( "    Options:\n\n" ) );
        wprintf_s( TEXT( "      -h   :  Print usage\n\n" ) );
        wprintf_s( TEXT( "    If no target dir is specified, then the current working dir will be used\n" ) );

        return 1;
    }
    else if ( ( argc < targetDirInd + 1 ) && ( workLength <= MAX_PATH - 3 ) )
    {
        // No target specified --> assume current dir
        wcscpy_s( targetDir, MAX_PATH, workDir );
    }
    else if ( argc == targetDirInd + 1 )
    {
        // One target specified

        // Validate target dir starting with '\'
        if ( argv[ targetDirInd ][ 0 ] == '\\' )
        {
            // Fetch drive letter from working dir
            wcsncpy_s( targetDir, MAX_PATH, workDir, 2 );
        }

        // Append passed dir to target dir
        wcscat_s( targetDir, MAX_PATH, argv[ targetDirInd ] );
    }

    // Set up absolute target dir --> resolve '.' and '..' in target dir
    if ( !SetCurrentDirectory( targetDir ) )
    {
        ReportError( TEXT( "\nTarget directory not found.\n" ), 0, TRUE );
        return 1;
    }

    // Display absolute target dir
    GetCurrentDirectory( _countof( targetDir ), targetDir );
    wprintf_s( TEXT( "\n    Target dir: \"%s\"\n\n" ), targetDir );

    // Initialize results list
    InitializeList( &resultsList );

    // Initialize list's name (measurement name)
    ptTchar = wcsrchr( targetDir, L'\\' );

    if ( ptTchar != NULL )
        IniListName( &resultsList, ptTchar + 1 );
    else
        IniListName( &resultsList, TEXT( "" ) );

    // Check mem availability
    if ( ListIsFull( &resultsList ) )
    {
        wprintf_s( TEXT( "\nNo memory available!\n" ) );
        return 1;
    }

    // Disable file system redirection
    wow64Disabled = Wow64DisableWow64FsRedirection( &oldValueWow64 );

    // Scan target dir
    scanDir( targetDir, &resultsList, &resultsItem );

    // Re-enable redirection
    if ( wow64Disabled )
    {
        if ( !( Wow64RevertWow64FsRedirection( oldValueWow64 ) ) )
            ReportError( TEXT( "Re-enable redirection failed." ), 1, TRUE );
    }

    // Display results
    if ( ListIsEmpty( &resultsList ) )
        wprintf_s( TEXT( "\nNo data.\n\n" ) );
    else
    {
        // Sort by name (a to Z)
        SortList( &resultsList, cmpItemsName );

        // Display sorted results
        showResults( &resultsList, &resultsItem );

        // Generate KML file
        outputKml( &resultsList );

    }

    // Housekeeping
    EmptyTheList( &resultsList );

    return 0;
}
Ejemplo n.º 22
0
int wmain( int argc, LPTSTR argv[] )
{
    // Declare vars
    TCHAR targetDir[ MAX_PATH ] = { 0 };
    TCHAR workDir[ MAX_PATH ] = { 0 };
    DWORD targetLength = 0;
    DWORD workLength = 0;
    Item resultsItem = { 0 };
    List resultsList = { 0 };
    LARGE_INTEGER freq;
    LARGE_INTEGER startingT, endingT, elapsedTicks;
    BOOL flags[ MAX_OPTIONS ] = { 0 };
    int targetDirInd = 0;
    PVOID oldValueWow64 = NULL;
    BOOL wow64Disabled = FALSE;

    // Fetch frec & initial ticks count
    QueryPerformanceFrequency( &freq );
    QueryPerformanceCounter( &startingT );

    // Get index of first argument after options
    // Also determine which options are active
    targetDirInd = Options( argc, argv,
        TEXT( "sfdmnthb" ),
        &flags[ FL_SIZE ], &flags[ FL_FILES ], &flags[ FL_DIRS ],
        &flags[ FL_MODIF ], &flags[ FL_NAME ], &flags[ FL_TYPE ],
        &flags[ FL_HELP ], &flags[ FL_DBG ], NULL );

    // Get current working dir
    workLength = GetCurrentDirectory( _countof( workDir ), workDir );

    // Validate target dir
    if ( ( argc > targetDirInd + 1 ) || flags[ FL_HELP ] )
    {
        // More than one target or
        // target with gaps (no quotes) specified or
        // asked for help

        // Print usage
        wprintf_s( TEXT( "\n    Usage:    dgl [options] [target dir]\n\n" ) );
        wprintf_s( TEXT( "    Options:\n\n" ) );
        wprintf_s( TEXT( "      -s   :  Sort by size [bytes] (default)\n" ) );
        wprintf_s( TEXT( "      -f   :  Sort by files count (descending)\n" ) );
        wprintf_s( TEXT( "      -d   :  Sort by dirs count (descending)\n" ) );
        wprintf_s( TEXT( "      -m   :  Sort by date modified (latest to earliest)\n" ) );
        wprintf_s( TEXT( "      -n   :  Soft by name (a to Z)\n" ) );
        wprintf_s( TEXT( "      -t   :  Sort by type (<DIR>, <LIN>, file)\n" ) );
        wprintf_s( TEXT( "      -h   :  Print usage\n" ) );
        wprintf_s( TEXT( "      -b   :  Extended output (debug purposes)\n\n" ) );
        wprintf_s( TEXT( "    If no option is specidied, then '-s' will be used\n" ) );
        wprintf_s( TEXT( "    If no target dir is specified, then the current working dir will be used\n" ) );

        return 1;
    }
    else if ( ( argc < targetDirInd + 1 ) && ( workLength <= MAX_PATH - 3 ) )
    {
        // No target specified --> assume current dir
        wcscpy_s( targetDir, MAX_PATH, workDir );
    }
    else if ( argc == targetDirInd + 1 )
    {
        // One target specified

        // Validate target dir starting with '\'
        if ( argv[ targetDirInd ][ 0 ] == '\\' )
        {
            // Fetch drive letter from working dir
            wcsncpy_s( targetDir, MAX_PATH, workDir, 2 );
        }

        // Append passed dir to target dir
        wcscat_s( targetDir, MAX_PATH, argv[ targetDirInd ] );
    }

    // Set up absolute target dir --> resolve '.' and '..' in target dir
    if ( !SetCurrentDirectory( targetDir ) )
    {
        ReportError( TEXT( "\nTarget directory not found.\n" ), 0, TRUE );
        return 1;
    }

    // Display absolute target dir
    GetCurrentDirectory( _countof( targetDir ), targetDir );
    wprintf_s( TEXT( "\n    Target dir: \"%s\"\n\n" ), targetDir );

    // Initialize results list
    InitializeList( &resultsList );
    if ( ListIsFull( &resultsList ) )
    {
        wprintf_s( TEXT( "\nNo memory available!\n" ) );
        return 1;
    }

    // Debug output
    if ( flags[ FL_DBG ] )
        wprintf_s( TEXT( "    %s\n" ), targetDir );

    // Disable file system redirection
    wow64Disabled = Wow64DisableWow64FsRedirection( &oldValueWow64 );

    // Scan target dir
    scanDir( targetDir, &resultsList, &resultsItem, TRUE, flags[ FL_DBG ] );

    // Re-enable redirection
    if ( wow64Disabled )
    {
        if ( !( Wow64RevertWow64FsRedirection( oldValueWow64 ) ) )
            ReportError( TEXT( "Re-enable redirection failed." ), 1, TRUE );
    }

    // Display results
    if ( ListIsEmpty( &resultsList ) )
        wprintf_s( TEXT( "\nNo data.\n\n" ) );
    else
    {
        // Sort results
        // if-else chain determines sorting priority
        // one sorting type high prio excludes low prio types
        if ( flags[ FL_SIZE ] )
            // Sort by size (descending)
            SortList( &resultsList, cmpItemsSizeCount );
        else if ( flags[ FL_FILES ] )
            // Sort by files count (descending)
            SortList( &resultsList, cmpItemsFilesCount );
        else if ( flags[ FL_DIRS ] )
            // Sort by dirs count (descending)
            SortList( &resultsList, cmpItemsDirsCount );
        else if ( flags[ FL_MODIF ] )
            // Sort by modification date (latest to earliest)
            SortList( &resultsList, cmpItemsLastWriteTime );
        else if ( flags[ FL_NAME ] )
            // Sort by name (a to Z)
            SortList( &resultsList, cmpItemsName );
        else
            // Default: sort by size (descending)
            SortList( &resultsList, cmpItemsSizeCount );

        // Debug output
        if ( flags[ FL_DBG ] )
            wprintf_s( TEXT( "\n" ) );

        // Display sorted results
        showResults( &resultsList, &resultsItem );
    }

    // Housekeeping
    EmptyTheList( &resultsList );

    // Fetch final ticks count
    QueryPerformanceCounter( &endingT );

    // Calc elapsed ticks
    elapsedTicks.QuadPart = endingT.QuadPart - startingT.QuadPart;

    // Calc and display elapsed time
    calcDispElapTime( &elapsedTicks.QuadPart, &freq.QuadPart );

    return 0;
}