Buffer & Buffer::operator =(const Buffer ©) { clear(); copyIn(copy); return *this; }
void perBeadBfMaskClass::init(BkgModelWorkInfo* pBkinfo) { assert(memTypeHost() || memTypeDevice()); if(memTypeHost()) { wrappPtr(&pBkinfo->bkgObj->GetGlobalStage().bfmask->mask[0]); } else { copyIn(&pBkinfo->bkgObj->GetGlobalStage().bfmask->mask[0]); } }
//---------------------------------------------------------------------------- int VectorReducer::copyInFieldDataLocalIDs(int fieldID, int idType, int numIDs, const int* localIDs, const double* data, int vectorIndex) { fei::SharedPtr<fei::VectorSpace> vspace = target_->getVectorSpace(); int fieldSize = vspace->getFieldSize(fieldID); int numIndices = numIDs*fieldSize; std::vector<int> indices(numIndices); int err = vspace->getGlobalIndicesLocalIDs(numIDs, localIDs, idType, fieldID, &indices[0]); if (err != 0) { throw std::runtime_error("fei::VectorReducer::copyInFieldData ERROR in vspace->getGlobalIndices."); } return(copyIn(numIndices, &indices[0], data, vectorIndex)); }
bool CursorWindow::putDouble(unsigned int row, unsigned int col, double value) { field_slot_t * fieldSlot = getFieldSlotWithCheck(row, col); if (!fieldSlot) { return false; } #if WINDOW_STORAGE_INLINE_NUMERICS fieldSlot->data.d = value; #else int offset = alloc(sizeof(int64_t)); if (!offset) { return false; } copyIn(offset, value); fieldSlot->data.buffer.offset = offset; fieldSlot->data.buffer.size = sizeof(double); #endif fieldSlot->type = FIELD_TYPE_FLOAT; return true; }
void parent(int pid, int pty) { unsigned char buf[BUFFER_SIZE]; int i; int val; int rc; if(verbose) { reportIso2022(outputState); } #ifdef SIGWINCH installHandler(SIGWINCH, sigwinchHandler); #endif installHandler(SIGCHLD, sigchldHandler); rc = copyTermios(0, pty); if(rc < 0) FatalError("Couldn't copy terminal settings\n"); rc = setRawTermios(); if(rc < 0) FatalError("Couldn't set terminal to raw\n"); val = fcntl(0, F_GETFL, 0); if(val >= 0) { fcntl(0, F_SETFL, val | O_NONBLOCK); } val = fcntl(pty, F_GETFL, 0); if(val >= 0) { fcntl(pty, F_SETFL, val | O_NONBLOCK); } setWindowSize(0, pty); for(;;) { rc = waitForInput(0, pty); if(sigwinch_queued) { sigwinch_queued = 0; setWindowSize(0, pty); } if(sigchld_queued && exitOnChild) break; if(rc > 0) { if(rc & 2) { i = read(pty, buf, BUFFER_SIZE); if((i == 0) || ((i < 0) && (errno != EAGAIN))) break; if(i > 0) copyOut(outputState, 0, buf, i); } if(rc & 1) { i = read(0, buf, BUFFER_SIZE); if((i == 0) || ((i < 0) && (errno != EAGAIN))) break; if(i > 0) copyIn(inputState, pty, buf, i); } } } restoreTermios(); }
///////////////////////////////////////////////// //perBeadT0CubeClass void perBeadT0CubeClass::init(BkgModelWorkInfo* pBkinfo) { copyIn( &(*(pBkinfo->smooth_t0_est))[0]); }
void Buffer::copyIn(const char *string) { copyIn(string, strlen(string)); }
void Buffer::copyIn(const std::string &string) { return copyIn(string.c_str(), string.size()); }
Buffer::Buffer(const void *data, size_t length) { m_readAvailable = m_writeAvailable = 0; m_writeIt = m_segments.end(); copyIn(data, length); }
Buffer::Buffer(const std::string &string) { m_readAvailable = m_writeAvailable = 0; m_writeIt = m_segments.end(); copyIn(string); }
Buffer::Buffer(const char *string) { m_readAvailable = m_writeAvailable = 0; m_writeIt = m_segments.end(); copyIn(string, strlen(string)); }
Buffer::Buffer(const Buffer ©) { m_readAvailable = m_writeAvailable = 0; m_writeIt = m_segments.end(); copyIn(copy); }
fei::Vector_Impl<T>::Vector_Impl(fei::SharedPtr<fei::VectorSpace> vecSpace, T* vector, int numLocalEqns, bool isSolutionVector, bool deleteVector) : Vector_core(vecSpace, numLocalEqns), vector_(vector), isSolution_(isSolutionVector), deleteVector_(deleteVector), localProc_(0), numProcs_(1), dbgprefix_("VecImpl: ") { if (strcmp(snl_fei::FEVectorTraits<T>::typeName(), "unsupported")) { setFEVector(true); } else { setFEVector(false); } localProc_ = fei::localProc(vecSpace->getCommunicator()); numProcs_ = fei::numProcs(vecSpace->getCommunicator()); if (output_level_ >= fei::BRIEF_LOGS && output_stream_ != NULL) { FEI_OSTREAM& os = *output_stream_; os << dbgprefix_<<" ctor, numLocalEqns="<<numLocalEqns <<", typeName: "<<typeName()<<FEI_ENDL; } std::vector<int> idTypes; vecSpace->getIDTypes(idTypes); std::vector<int> eqns; std::vector<double> zeros; for(size_t i=0; i<idTypes.size(); ++i) { int idType = idTypes[i]; fei::SharedIDs<int>& sharedIDs = vecSpace->getSharedIDs(idType); const fei::SharedIDs<int>::map_type& idMap = sharedIDs.getSharedIDs(); fei::SharedIDs<int>::map_type::const_iterator iter = idMap.begin(), iterEnd = idMap.end(); for(; iter!=iterEnd; ++iter) { int ID = iter->first; int eqn; vecSpace->getGlobalIndex(idType, ID, eqn); int ndof = vecSpace->getNumDegreesOfFreedom(idType, ID); eqns.resize(ndof); zeros.resize(ndof, 0.0); for(int j=0; j<ndof; ++j) eqns[j] = eqn+j; if (!isSolutionVector) { sumIn(ndof, &eqns[0], &zeros[0]); } else { copyIn(ndof, &eqns[0], &zeros[0]); } } } setCommSizes(); std::vector<CSVec*>& remoteVecs = remotelyOwned(); for(size_t i=0; i<remoteVecs.size(); ++i) { remoteVecs[i]->clear(); } }
int main() { system("clear"); BookList_t*List = malloc(sizeof(BookList_t)); if (!List) return 0; List->first = NULL; List->last = NULL; int temp = 0; int choice; MainMenu:system ("clear"); mainmenu(); //MainMenu Iniziale printf("\nChoice: "); scanf("%d", &choice); while(choice!=5) //Riferito al mainmenu iniziale, esco solo con 5 -> END PROGRAM { switch (choice) { //::::::::::::::::::::::::::::::::::::::::FUNC:INSERT::::::::::::::::::::::::::::::::::::::::::: case 1: while (1){ system("clear"); printf("Insert the element:\n1)At the top of the list.\n2)At the end of the list.\n\n0)Main Menu\n\n"); scanf ("%d", &temp); if (temp == 1) { //Insert Head________________________ system("clear"); printf("Enter the book:\n"); insHead(List); printList(List); printf("Press any number to continue.."); scanf("%d", &temp); system("clear"); break;} else if (temp == 2){ //Insert Tail________________________ system("clear"); printf("Enter the book:\n"); insTail(List); printList(List); printf("Press any number to continue..\n"); scanf("%d", &temp); system("clear"); break;} else if (temp == 0) { goto MainMenu; } else { printf ("Please Insert a valid Number\a\n"); printf("Press any number to continue..\n"); scanf("%d", &temp); } } //::::::::::::::::::::::::::::::::::::::::FUNC:REMOVE::::::::::::::::::::::::::::::::::::::::::: case 2: while (1){ system("clear"); printf("Remove the element:\n1)At the top of the list.\n2)At the end of the list \n3)Remove from id.\n\n0)Main Menu\n\n"); scanf ("%d", &temp); if (temp == 1) { //Remove Head________________________ system ("clear"); printf("Book removed successfully.\n"); rmvHead(List); printf("Press any number to continue..\n"); scanf("%d", &temp); break;} else if (temp == 2){ //Remove Tail________________________ system ("clear"); rmvTail(List); printf("Book removed successfully.\n"); printf("Press any number to continue.."); scanf("%d", &temp); break;} else if (temp == 3){ //Remove From ID_____________________ system ("clear"); printf("Enter the book's id you want to delete:\n"); Cell_t* Ptr = searchId(List); Cell_t *Temp = List->first; if (Ptr != NULL) while(Temp != Ptr) { Temp = Temp->pNext; Temp->pNext = NULL; free(Ptr); Ptr = Temp; printf("Press any number to continue.."); scanf("%d", &temp); break; } } else if (temp == 0) { goto MainMenu; } else { printf ("Please Insert a valid Number\a\n"); printf("Press any number to continue..\n"); scanf("%d", &temp); } } //::::::::::::::::::::::::::::::::::::FUNC:LOAN:RETURN::::::::::::::::::::::::::::::::::::::::: case 3: while (1){ system("clear"); printf("Which action do you want to do?:\n1)Loan a book.\n2)Return a book.\n\n0)Main Menu\n\n"); scanf("%d", &temp); if (temp == 1){ system ("clear"); //Copyout________________ copyOut(List); printf("Function worked correctly.\n"); printf("Press any number to continue..\n"); scanf("%d", &temp); break;} else if (temp == 2){ //Copyin________________________ system ("clear"); copyIn(List); printf("Function worked correctly.\n"); printf("Press any number to continue..\n"); scanf("%d", &temp); break; } else if (temp == 0) goto MainMenu; else { printf ("Please Insert a valid Number\a\n"); printf("Press any number to continue..\n"); scanf("%d", &temp); } } //::::::::::::::::::::::::::::::::::::::FUNC:SEE:LIST::::::::::::::::::::::::::::::::::::::::::: case 4: while (1){ system("clear"); printf("What do you want to see?\n1)The List\n2)A specific book\n3)To check if the book is in the list\n\n0)Main Menu\n\n"); scanf ("%d", &temp); if (temp == 1){ //see the list_________________________________________ system ("clear"); printList(List); printf("Press any number to continue..\n"); scanf("%d", &temp); break; } else if (temp ==2){ //see a specific book______________________________ system ("clear"); printf("Enter the id:\n"); Cell_t *p = searchId(List); if(p != NULL){ printElem(p->book); printf("Press any number to continue..\n"); scanf("%d", &temp); break;} else { printf("No book with this id available.\n"); printf("Press any number to continue..\n"); scanf("%d", &temp); break;} } else if (temp==3){//To controll if the book is in the list_____________ system ("clear"); printf("Enter the id to see if the book is in the list:\n"); Cell_t *ren = searchId(List); if (ren != NULL) { printf("TRUE - In List\n"); printf("Press any number to continue..\n"); scanf("%d", &temp); break;} else { printf("FALSE - Not in list\n"); printf("Press any number to continue..\n"); scanf("%d", &temp); break;} } else if (temp == 0) { goto MainMenu; } else { printf ("Please Insert a valid Number\a\n"); printf("Press any number to continue..\n"); scanf("%d", &temp); } } } //::::::::::::::::::::::::::::::::::::::FINE:FUNZIONI::::::::::::::::::::::::::::::::::::::::::: system ("clear"); mainmenu(); printf("\nChoice: "); scanf("%d", &choice); } //Fine While system ("clear"); int e = 0; finalpiont: printf("\nExiting...\n\nAre you sure?\n1)Yes\n2)No\n"); scanf("%d", &e); if (e == 1){ system ("clear"); printf("\nThanks for using -Book's Registration Program-\n\nCopyright © 2016 Matteo Peruzzi. All rights reserved.\n\n\n"); return 0; } else if (e == 2) { system("clear"); goto MainMenu; } else { system ("clear"); printf ("Please Insert a valid Number\a\n"); goto finalpiont; } }