Пример #1
0
void TableManager::initialize() {
	//index 초기화
	fdtLastIndex = -1;
	inodeLastIndex = -1;
	sftLastIndex = -1;

	//Pointer 초기화
	fileDescriptorTable = NULL;
	inodeTable = NULL;
	systemFileTable = NULL;

	//Max Value 초기화
	fdtMax = TABLE_DEFAULT_MAX;
	inodeMax = TABLE_DEFAULT_MAX;
	sftMax = TABLE_DEFAULT_MAX;

	fileDescriptorTable = new int[fdtMax];

	inodeTable = new InodeElement[inodeMax];
	systemFileTable = new SFTElement[sftMax];

	//-1로 초기화
	tableInit(FDT);
	tableInit(INODET);
	tableInit(SFT);

	//Reserved
	fileDescriptorTable[0] = 0; // 표준 입력
	fileDescriptorTable[1] = 1; // 표준 출력
	fileDescriptorTable[2] = 2; // 표준 오류
	fdtLastIndex = 2;
}
Пример #2
0
void hBoxInit(hBox *self, const char *id)
{
	// Init our parent
	tableInit((table *) self, id);

	// Prepare our vtable
	hBoxInitVtbl(self);

	// Set our type
	WIDGET(self)->classInfo = &hBoxClassInfo;
}
Пример #3
0
void TableManager::resize(TableType type) {

	if (type == FDT) {
		int* newFDT = new int[fdtMax * 2];
		tableInit(type, newFDT, fdtMax * 2);
		for (int i = 0; i <= fdtLastIndex; i++) {
			newFDT[i] = fileDescriptorTable[i];
		}
		delete[] fileDescriptorTable;
		fileDescriptorTable = newFDT;
		fdtMax *= 2;
	}
	else if (type == INODET)
	{
		InodeElement* newInodeTable = new InodeElement[inodeMax * 2];
		tableInit(type, newInodeTable, inodeMax * 2);
		for (int i = 0; i <= inodeLastIndex; i++) {
			newInodeTable[i] = inodeTable[i];
		}
		delete[] inodeTable;
		inodeTable = newInodeTable;
		inodeMax *= 2;
	}
	else if (type == SFT)
	{
		SFTElement* newSFT = new SFTElement[sftMax * 2];
		tableInit(type, newSFT, sftMax * 2);
		for (int i = 0; i <= sftLastIndex; i++) {
			newSFT[i] = systemFileTable[i];
		}
		delete[] systemFileTable;
		systemFileTable = newSFT;
		sftMax *= 2;
	}
	else {
		cout << "error in TableManager.cpp, resize Func" << endl;
	}
}
Пример #4
0
table *tableCreate(const char *id)
{
	table *instance = malloc(sizeof(table));
	
	if (instance == NULL)
	{
		return NULL;
	}
	
	// Call the constructor
	tableInit(instance, id);
	
	// Return the new object
	return instance;
}
Пример #5
0
int main() {
   TTable mujTable;
   table = &mujTable;
   tableInit(table);

   tableInsertFunction(table, strCreateString("fce"));
   functionInsertVar(table->lastAddedFunc, strCreateString("x"));
   functionInsertVar(table->lastAddedFunc, strCreateString("y"));
   functionInsertVar(table->lastAddedFunc, strCreateString("z"));

   printf("\nJedna funkce: \n");
   tablePrintOrder(*table);
   printf("\n----------------------------\n");


//tiskniPrecTab();
   FILE *f = fopen("testy/test-expr2.txt","r");
   setSourceFile(f);
   strInit(&attr);
   listInit(&table->lastAddedFunc->tmpVar);

   int err = EOK;
   TVar *x = NULL;
   int test = 1;
   token = 1;

   while(token != END_OF_FILE) {
      token = getNextToken(&attr);
      x = NULL;
      err = parseExpression(table, &x);
      printf("Test %d skoncil s chybou: %d a vysledkem: %d \n", test,err, (int)x);
      test++;

      while (token != END_OF_FILE && token != L_SEMICOLON) {
         token = getNextToken(&attr);
      }
   }
   tiskniList(&table->lastAddedFunc->instructions);

   listDataDelete(&table->lastAddedFunc->tmpVar);
   listDispose(&table->lastAddedFunc->tmpVar);

   fclose(f);
   tableClear(table);
   strFree(&attr);
   return EXIT_SUCCESS;
}
Пример #6
0
RoomListDialog::RoomListDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::RoomListDialog),
    dataPort_(0),
    msgPort_(0),
    historySize_(0),
    socket(nullptr),
    newRoomWindow(new NewRoomWindow(this))
{
    ui->setupUi(this);
    connect(ui->pushButton_4,&QPushButton::clicked,
            this, &RoomListDialog::reject);
    connect(ui->pushButton_4,&QPushButton::clicked,
            this, &RoomListDialog::saveNick);
    connect(ui->pushButton_3,&QPushButton::clicked,
            this, &RoomListDialog::requestRoomList);
    connect(ui->pushButton_2,&QPushButton::clicked,
            this, &RoomListDialog::requestJoin);
    connect(ui->tableWidget,&QTableWidget::cellDoubleClicked,
            this,&RoomListDialog::requestJoin);
    connect(ui->checkBox, &QCheckBox::clicked,
            this,&RoomListDialog::filterRoomList);

    connect(ui->pushButton, &QPushButton::clicked,
            newRoomWindow, &NewRoomWindow::show);
    connect(newRoomWindow, &NewRoomWindow::newRoom,
            this,&RoomListDialog::requestNewRoom);
    connect(newRoomWindow, &NewRoomWindow::finished,
            this,&RoomListDialog::requestRoomList);
    connect(&Singleton<CommandSocket>::instance(), &CommandSocket::connected,
            this, &RoomListDialog::onCmdServerConnected);
    connect(&Singleton<CommandSocket>::instance(), &CommandSocket::newData,
            this, &RoomListDialog::onCmdServerData);

    tableInit();
    socketInit();
    timer = new QTimer(this);
    connect(timer,&QTimer::timeout,
            this,&RoomListDialog::requestRoomList);
    timer->start(10000);
    loadNick();
    clientId_ = loadClientId();

}
Пример #7
0
Table* tableCreate(
				int m,
				int (*fHash) (const Key, int),
				int (*fKeyCmp) (const Key, const Key),
				enum RehashType eRehashType,
				void (*fCopyElement) (Element*, const Element*),
				void (*fReleaseElement) (Element*)
				)
{
	Table* pTab = NULL;

	pTab = (Table*) malloc(sizeof(Table));
	tableInit(
			pTab,
			m,
			fHash,
			fKeyCmp,
			eRehashType,
			fCopyElement,
			fReleaseElement);

	return pTab;
}
Пример #8
0
hashMapOpen::hashMapOpen (logger *log)
    : hashMap(log)
{
    tableInit();
}
Пример #9
0
hashMapOpen::hashMapOpen (int tableLength, logger *log)
    : hashMap(tableLength, log)
{
    tableInit();
}
Пример #10
0
int main() {
   TTable table;
   tableInit(&table);

   printf("\nTabulka by mela byt prazdna: \n");
   tablePrintOrder(table);
   printf("\n----------------------------\n");

   tableInsertFunction(&table, strCreateString("func1"));
   functionInsertVar(table.lastAddedFunc, strCreateString("var1func1"));
   functionInsertVar(table.lastAddedFunc, strCreateString("var2func1"));
   functionInsertVar(table.lastAddedFunc, strCreateString("var3func1"));

   printf("\nJedna funkce: \n");
   tablePrintOrder(table);
   printf("\n----------------------------\n");

   tableInsertFunction(&table, strCreateString("func2"));
   functionInsertVar(table.lastAddedFunc, strCreateString("var1func2"));
   functionInsertVar(table.lastAddedFunc, strCreateString("var2func2"));
   functionInsertVar(table.lastAddedFunc, strCreateString("var3func2"));

   printf("\nDve funkce: \n");
   tablePrintOrder(table);
   printf("\n----------------------------\n");

   tableInsertFunction(&table, strCreateString("func3"));
   functionInsertVar(table.lastAddedFunc, strCreateString("var1func3"));
   functionInsertVar(table.lastAddedFunc, strCreateString("var2func3"));
   functionInsertVar(table.lastAddedFunc, strCreateString("var3func3"));

   printf("\nVsechny: \n");
   tablePrintOrder(table);
   printf("\n----------------------------\n");

   // test heldani
   {

      TFunction *fceSearch;

      printf("\nObsahuje tabulka funkci %s? \t", "func1");
      fceSearch = tableSearchFunction(&table, strCreateString("func1"));
      if(fceSearch != NULL) {
         printf("ANO\n");
         printf("   Obsahuje funkce promenou %s?\t", "var1func1");
         if(functionSearchVar(fceSearch, strCreateString("var1func1")) != NULL)
            printf("ANO");
         else
            printf("NE");
      } else
         printf("NE\n");

      printf("\nObsahuje tabulka funkci %s? \t", "funcX");
      fceSearch = tableSearchFunction(&table, strCreateString("funcX"));
      if(fceSearch != NULL) {
         printf("ANO\n");
         printf("   Obsahuje funkce promenou %s?\t", "var1func1");
         if(functionSearchVar(fceSearch, strCreateString("var1func1")) != NULL)
            printf("ANO");
         else
            printf("NE");
      } else
         printf("NE\n");

      printf("\n----------------------------\n");
   }


   // test zásobníku:
   printf("TEST ZASOBNIKU:\n");
   printf("----------------------------\n");

   TStack s;
   stackInit(&s);

   prazdnyStack(s);

   TFunction *fce = tableSearchFunction(&table, strCreateString("func2"));
   TVar *id = functionSearchVar(fce, strCreateString("var1func2"));
   stackPush(&s, (void*)id);

   prazdnyStack(s);
   tiskniStack(&s);

   id = functionSearchVar(fce, strCreateString("var2func2"));
   stackPush(&s, (void*)id);
   tiskniStack(&s);
   id = functionSearchVar(fce, strCreateString("var3func2"));
   stackPush(&s, (void*)id);
   tiskniStack(&s);
   id = functionSearchVar(fce, strCreateString("var1func2"));
   stackPush(&s, (void*)id);
   tiskniStack(&s);


   TVar *data = (TVar*)stackTopPop(&s);
   if (data != NULL)  printf("Vybráno ze zásobníku: %s\n",data->name);
   else printf("Ukazatel je nulový! \n");
   prazdnyStack(s);

   data = (TVar*)stackTopPop(&s);
   if (data != NULL)  printf("Vybráno ze zásobníku: %s\n",data->name);
   else printf("Ukazatel je nulový! \n");
   prazdnyStack(s);

   data = (TVar*)stackTopPop(&s);
   if (data != NULL)  printf("Vybráno ze zásobníku: %s\n",data->name);
   else printf("Ukazatel je nulový! \n");
   prazdnyStack(s);

   tiskniStack(&s);
   stackDelete   (&s);
   prazdnyStack(s);
   tiskniStack(&s);

   data = (TVar*)stackTopPop(&s);
   if (data != NULL)  printf("Vybráno ze zásobníku: %s\n",data->name);
   else printf("Ukazatel je nulový! \n");
   printf("----------------------------\n");

   // test seznamu:
   printf("TEST SEZNAMU:\n");
   printf("----------------------------\n");


   TList L;
   listInit (&L);
   id = functionSearchVar(fce, strCreateString("var1func2"));
   TLItem *uk2 = listGetActive (&L);
   listSetActive(&L, uk2);
   aktivniList(L);

   listInsertLast(&L, id);
   tiskniList(&L);

   void *uk4 = listCopyLast(&L);
   printf("Zkopírováno:  %s\n",((TVar*)uk4)->name);


   aktivniList(L);
   listFirst(&L);
   tiskniList(&L);

   listLast(&L);
   tiskniList(&L);

   id = functionSearchVar(fce, strCreateString("var2func2"));
   listPostInsert(&L, id);
   tiskniList(&L);

   id = functionSearchVar(fce, strCreateString("var3func2"));
   listInsertLast(&L, id);
   tiskniList(&L);


   id = functionSearchVar(fce, strCreateString("var1func2"));
   listInsertLast(&L, id);
   tiskniList(&L);

   listFirst(&L);
   listSucc(&L);
   TLItem *uk = listGetActive (&L);
   tiskniList(&L);

   listLast(&L);
   tiskniList(&L);

   listSetActive(&L, uk);
   tiskniList(&L);

   aktivniList(L);
   listDeleteFirst(&L);
   tiskniList(&L);

   void *uk3 = listCopyLast(&L);
   printf("Zkopírováno:  %s\n",((TVar*)uk3)->name);
   listSucc(&L);
   tiskniList(&L);

   listActualize(&L, uk3);
   tiskniList(&L);

   listDispose (&L);
   printf("----------------------------\n");
   // konec testu seznamu

   printf("\nSmazu: \n");
   tableClear(&table);
   tablePrintOrder(table);
   printf("\n----------------------------\n");
}
Пример #11
0
int dfaExport(DFA *a, char *filename, int num, char *vars[], char orders[])
{
  Table *table = tableInit(); 
  int i;
  FILE *file;

  if (filename) {
    if ((file = fopen(filename, "w")) == 0) 
      return 0;
  }
  else
    file = stdout;
  
  /* remove all marks in a->bddm */
  bdd_prepare_apply1(a->bddm); 
  
  /* build table of tuples (idx,lo,hi) */
  for (i = 0; i < a->ns; i++)  
    export(a->bddm, a->q[i], table);

  /* renumber lo/hi pointers to new table ordering */
  for (i = 0; i < table->noelems; i++) {
    if (table->elms[i].idx != -1) {
      table->elms[i].lo = bdd_mark(a->bddm, table->elms[i].lo) - 1;
      table->elms[i].hi = bdd_mark(a->bddm, table->elms[i].hi) - 1;
    }
  }

  /* write to file */
  fprintf(file,
          "MONA DFA\n"
	  "number of variables: %u\n"
	  "variables:", num);
  for (i = 0; i < num; i++)
    fprintf(file, " %s", vars[i]);
  fprintf(file, "\n"
	  "orders:");
  for (i = 0; i < num; i++)
    fprintf(file, " %u", (unsigned) orders[i]);
  fprintf(file, "\n"
          "states: %u\n"
          "initial: %u\n"
          "bdd nodes: %u\n"
          "final:",
	  a->ns, a->s, table->noelems); 
  for (i = 0; i < a->ns; i++)
    fprintf(file, " %d", a->f[i]);
  fprintf(file, "\nbehaviour:");
  for (i = 0; i < a->ns; i++)
    fprintf(file, " %u", bdd_mark(a->bddm, a->q[i]) - 1);
  fprintf(file, "\nbdd:\n");
  for (i = 0; i < table->noelems; i++) 
    fprintf(file, " %i %u %u\n", 
	    table->elms[i].idx, table->elms[i].lo, table->elms[i].hi);
  fprintf(file, "end\n");

  tableFree(table);
  if (filename)
    fclose(file);
  return 1;
}