TEST_F(CoreContextTest, InitiateOrder) { AutoCurrentContext testCtxt; testCtxt->Initiate(); // Initiate inner to outer { auto outerCtxt = testCtxt->Create<void>(); auto middleCtxt = outerCtxt->Create<void>(); auto innerCtxt = middleCtxt->Create<void>(); innerCtxt->Initiate(); middleCtxt->Initiate(); outerCtxt->Initiate(); ASSERT_TRUE(outerCtxt->IsRunning()) << "Context not running after begin initiated"; ASSERT_TRUE(middleCtxt->IsRunning()) << "Context not running after begin initiated"; ASSERT_TRUE(innerCtxt->IsRunning()) << "Context not running after begin initiated"; outerCtxt->SignalShutdown(true); } // Initiate outer to inner { auto outerCtxt = testCtxt->Create<void>(); auto middleCtxt = outerCtxt->Create<void>(); auto innerCtxt = middleCtxt->Create<void>(); outerCtxt->Initiate(); middleCtxt->Initiate(); innerCtxt->Initiate(); ASSERT_TRUE(outerCtxt->IsRunning()) << "Context not running after begin initiated"; ASSERT_TRUE(middleCtxt->IsRunning()) << "Context not running after begin initiated"; ASSERT_TRUE(innerCtxt->IsRunning()) << "Context not running after begin initiated"; outerCtxt->SignalShutdown(true); } // Initiate middle, inner, then outer { auto outerCtxt = testCtxt->Create<void>(); auto middleCtxt = outerCtxt->Create<void>(); auto innerCtxt = middleCtxt->Create<void>(); middleCtxt->Initiate(); innerCtxt->Initiate(); outerCtxt->Initiate(); ASSERT_TRUE(outerCtxt->IsRunning()) << "Context not running after begin initiated"; ASSERT_TRUE(middleCtxt->IsRunning()) << "Context not running after begin initiated"; ASSERT_TRUE(innerCtxt->IsRunning()) << "Context not running after begin initiated"; outerCtxt->SignalShutdown(true); } }
void CWsDirectScreenAccess::GetRegion(TInt aNumRects) { #if defined(_DEBUG) if (iStatus!=EDirectStatusInitialising) iWsOwner->PPanic(EWservPanicDirectMisuse); #endif STACK_REGION region; iWin->GenerateTopRegion(region); const TInt regionCount=region.Count(); if (region.Count()==aNumRects) { iVisible.Copy(region); if (iVisible.CheckError()) { iStatus=EDirectStatusNone; SetReply(KErrNotReady); } else { TPtrC8 rectList(REINTERPRET_CAST(const TUint8*,region.RectangleList()),region.Count()*sizeof(TRect)); CWsClient::ReplyBuf(rectList); iStatus=EDirectStatusRunning; Initiate(); iMsgQueue->Started(); SetReply(KMaxTInt); } }
NS_IMETHODIMP nsAbLDAPDirectory::DeleteCards(nsIArray *aCards) { PRUint32 cardCount; PRUint32 i; nsCAutoString cardDN; nsresult rv = aCards->GetLength(&cardCount); NS_ENSURE_SUCCESS(rv, rv); for (i = 0; i < cardCount; ++i) { nsCOMPtr<nsIAbLDAPCard> card(do_QueryElementAt(aCards, i, &rv)); if (NS_FAILED(rv)) { NS_WARNING("Wrong type of card passed to nsAbLDAPDirectory::DeleteCards"); break; } // Set up the search ldap url - this is mURL rv = Initiate(); NS_ENSURE_SUCCESS(rv, rv); rv = card->GetDn(cardDN); NS_ENSURE_SUCCESS(rv, rv); // Launch query rv = DoModify(this, nsILDAPModification::MOD_DELETE, cardDN, nsnull, EmptyCString(), EmptyCString()); NS_ENSURE_SUCCESS(rv, rv); } return NS_OK; }
/* * * nsAbDirSearchListenerContext methods * */ NS_IMETHODIMP nsAbLDAPDirectory::OnSearchFinished(PRInt32 aResult, const nsAString &aErrorMessage) { nsresult rv = Initiate(); NS_ENSURE_SUCCESS(rv, rv); nsAutoLock lock(mLock); mPerformingQuery = PR_FALSE; return NS_OK; }
TEST_F(ContextCreatorTest, TeardownListenerTest) { // Create a context and verify teardown happens as expected AutoCreateContext mainContext; CurrentContextPusher pusher(mainContext); AutoRequired<ContextCreator<mySigil, int>> creator; { auto subctxt = creator->CreateContext(0).first; auto brc = subctxt->Inject<Runnable>(); subctxt->Initiate(); } creator->Clear(true); ASSERT_TRUE(true) << "Really all this test has to do is not crash by this point."; }
NS_IMETHODIMP nsAbLDAPDirectory::HasCard(nsIAbCard* card, PRBool* hasCard) { nsresult rv = Initiate (); NS_ENSURE_SUCCESS(rv, rv); // Enter lock nsAutoLock lock (mLock); *hasCard = mCache.Get(card, nsnull); if (!*hasCard && mPerformingQuery) return NS_ERROR_NOT_AVAILABLE; return NS_OK; }
void create(Lnode *head) { //head=(Lnode *) malloc (sizeof(Lnode)); Initiate(head); //head->next=NULL; p=head; printf("x=?"); scanf("%d",&x); while(x!=-999) { ptr=(Lnode *) malloc(sizeof(Lnode)); ptr->data=x; ptr->next=NULL; p->next=ptr; p=ptr; printf("x=?"); scanf("%d",&x); } }
int CSocketServerUDP::Start(SocketMode mode) { int ret=0; if (m_param->serverport<1 || m_param->serverport>=65535) { WriteLog("请填写正确的接收服务器端口号"); return -1; } if ((ret = Initiate())!=0) { return ret; } //开始接收数据 m_bStop=false; recive_pool_prt->schedule(boost::bind(&CSocketServerUDP::ReciveMsg,this)); return ret; }
int main() { int i; BiTreeNode *q[MaxSize+1]; BiTreeNode *root; int left,right,temp; int Num[MaxSize]={0}; char strA[MaxSize]="befcgdh";//pre_order char strB[MaxSize]="febgchd";//in_order char point;int n; n=strlen(strA); Initiate(&root); for(i=0;i<n;i++) { point=strA[i]; temp=Search(strB,point); left=SearchLeft(Num,temp); right=SearchRight(Num,temp); if(left==-1&&right==-1) { q[temp]=InsertLeftNode(root,point); Num[temp]=1; } else if(left!=-1&&q[left]->rightChild==NULL) { q[temp]=InsertRightNode(q[left],point); Num[temp]=1; } else if(right!=-1&&q[right]->leftChild==NULL) { q[temp]=InsertLeftNode(q[right],point); Num[temp]=1; } } PrintBiTree(root,0); printf("****************************************\n\n"); printf("PreOrder: \t"); PreOrder(root->leftChild,Visit); printf("\nInOrder:\t"); InOrder(root->leftChild,Visit); printf("\nPostOrder: \t"); PostOrder(root->leftChild,Visit); printf("\n*****************************************************************************\n\t\t\t\bCopyright @ 2009 Gary All Right Reserved\n"); return 0; }
NS_IMETHODIMP nsAbLDAPDirectory::OnSearchFoundCard(nsIAbCard* card) { nsresult rv = Initiate(); NS_ENSURE_SUCCESS(rv, rv); // Enter lock { nsAutoLock lock(mLock); mCache.Put(card, card); } // Exit lock nsCOMPtr<nsIAbManager> abManager = do_GetService(NS_ABMANAGER_CONTRACTID, &rv); if(NS_SUCCEEDED(rv)) abManager->NotifyDirectoryItemAdded(this, card); return NS_OK; }
nsresult nsAbQueryLDAPMessageListener::Cancel () { nsresult rv; rv = Initiate(); NS_ENSURE_SUCCESS(rv, rv); nsAutoLock lock(mLock); if (mFinished || mCanceled) return NS_OK; mCanceled = PR_TRUE; if (!mFinished) mWaitingForPrevQueryToFinish = PR_TRUE; return NS_OK; }
NS_IMETHODIMP nsAbLDAPDirectory::StopSearch () { nsresult rv = Initiate(); NS_ENSURE_SUCCESS(rv, rv); // Enter lock { nsAutoLock lockGuard(mLock); if (!mPerformingQuery) return NS_OK; mPerformingQuery = PR_FALSE; } // Exit lock if (!mDirectoryQuery) return NS_ERROR_NULL_POINTER; return mDirectoryQuery->StopQuery(mContext); }
int CSocketClientTCP::ConnectToServer() { int ret=Initiate(); if (ret!=0) { stringstream strss; strss<<"Soket初始化失败!错误信息:"<<GetErrorDetails(WSAGetLastError()); WriteLog(strss.str()); return -1; } if ((ret = connect(m_Socket,(sockaddr*)&m_ServerAddr,sizeof(m_ServerAddr))) == SOCKET_ERROR) { stringstream strss; strss<<"连接服务器失败!错误信息:"<<GetErrorDetails(WSAGetLastError()); WriteLog(strss.str()); return ret; } return ret; }
/// WindowsWrapper WinMainWrap /// This function should be called from the user's WinMain Function. /// It handles initiating, running and shutting down the engine and game. /// \param hInstance Handle to the window. /// \param pGame Pointer to an object derived from GameBase. /// \param loadingTexture A image name to be used as the loading screen. /// The texture will be loaded from the default texture directory. This /// parameter can be se to NULL resulting in no loading screen. /// \param shaderDebugging Optional parameter specifying whether or not you /// will be debugging a pixel/vertex shader. Setting this to true will create /// the device in software. This parameter defaults to false. void WindowsWrapper::WinMainWrap(HINSTANCE hInstance, GameBase* pGame, const char* loadingTexture, bool shaderDebugging) { // save pointer to game object derived from class GameBase m_pGame = pGame; // save a global pointer to the game gGameBase = pGame; // save the instance of the window hInstApp = hInstance; // Create the window and initate the engine Initiate(shaderDebugging, loadingTexture); // Run the actual game RunProgram(); // Shutdown the game engine and destroy the window Shutdown(); return; }
int main(void) { HashTable myHashTable; DataType a[]={180,750,600,430,541,900,460},item={430}; int i,j,k,n=7,m=13; /* m is the size of hashlist*/ Initiate(&myHashTable,m); for(i=0;i<n;i++) Insert(&myHashTable,a[i]); for(i=0;i<n;i++) { j=Find(&myHashTable,a[i]); printf("j=%d ht[]= %d\n",j,myHashTable.ht[j].data.key); } k=Find(&myHashTable,item); if(k>0) printf("查找成功,元素%d 的地址是 %d\n",item.key,k); else printf("查找失败\n"); Delete(&myHashTable,item); k=Find(&myHashTable,item); if(k>0) printf("查找成功,元素%d 的地址是 %d\n",item.key,k); else printf("查找失败\n"); Destroy(&myHashTable); return 0; }
InputBufferedStream::InputBufferedStream(IByteReaderWithPosition* inSourceReader,IOBasicTypes::LongBufferSizeType inBufferSize) { Initiate(inSourceReader,inBufferSize); }
int main(void) { int choose; int initsize = 20; KeyType key; char value[256] = {0}; HashTable myHashTable; DataType *data = NULL; HashItem *result = NULL; Initiate(&myHashTable,initsize); do{ showhelp(); printf("please input your choose:\n"); scanf("%d",&choose); switch(choose) { case 1: data = (DataType *)malloc(sizeof(DataType)); printf("Please input the key(int):"); scanf("%d",&(data->key)); printf("Please input the value(string):"); scanf("%s",data->value); if(Insert(&myHashTable,data) == 1) { printf("Add successfully!\n"); }else { printf("Add failed!\n"); } break; case 2: printf("Please input the key(int):"); scanf("%d",&key); result = Find(&myHashTable,key); if(result == NULL) { printf("Not Existed!\n"); }else { printf("The key is %d,the value is %s\n",key,result->data->value); } break; case 3: printf("Please input the key(int):"); scanf("%d",&key); if(Delete(&myHashTable,key) == 1) { printf("Delete successfully!\n"); }else { printf("Delete failed!\n"); } break; case 4: Traverse(&myHashTable); break; case 5: Destroy(&myHashTable); exit(0); default: break; } }while(1); }
NS_IMETHODIMP nsAbLDAPDirectory::ModifyCard(nsIAbCard *aUpdatedCard) { NS_ENSURE_ARG_POINTER(aUpdatedCard); nsCOMPtr<nsIAbLDAPAttributeMap> attrMap; nsresult rv = GetAttributeMap(getter_AddRefs(attrMap)); NS_ENSURE_SUCCESS(rv, rv); // Get the LDAP card nsCOMPtr<nsIAbLDAPCard> card = do_QueryInterface(aUpdatedCard, &rv); NS_ENSURE_SUCCESS(rv, rv); rv = Initiate(); NS_ENSURE_SUCCESS(rv, rv); // Retrieve preferences nsCAutoString prefString; rv = GetObjectClasses(prefString); NS_ENSURE_SUCCESS(rv, rv); CharPtrArrayGuard objClass; rv = SplitStringList(prefString, objClass.GetSizeAddr(), objClass.GetArrayAddr()); NS_ENSURE_SUCCESS(rv, rv); // Process updates nsCOMPtr<nsIArray> modArray; rv = card->GetLDAPMessageInfo(attrMap, objClass.GetSize(), objClass.GetArray(), nsILDAPModification::MOD_REPLACE, getter_AddRefs(modArray)); NS_ENSURE_SUCCESS(rv, rv); // Get current DN nsCAutoString oldDN; rv = card->GetDn(oldDN); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsILDAPService> ldapSvc = do_GetService( "@mozilla.org/network/ldap-service;1", &rv); NS_ENSURE_SUCCESS(rv, rv); // Retrieve base DN and RDN attributes nsCAutoString baseDN; nsCAutoString oldRDN; CharPtrArrayGuard rdnAttrs; rv = ldapSvc->ParseDn(oldDN.get(), oldRDN, baseDN, rdnAttrs.GetSizeAddr(), rdnAttrs.GetArrayAddr()); NS_ENSURE_SUCCESS(rv, rv); // Calculate new RDN and check whether it has changed nsCAutoString newRDN; rv = card->BuildRdn(attrMap, rdnAttrs.GetSize(), rdnAttrs.GetArray(), newRDN); NS_ENSURE_SUCCESS(rv, rv); if (newRDN.Equals(oldRDN)) { // Launch query rv = DoModify(this, nsILDAPModification::MOD_REPLACE, oldDN, modArray, EmptyCString(), EmptyCString()); } else { // Build and store the new DN nsCAutoString newDN(newRDN); newDN.AppendLiteral(","); newDN.Append(baseDN); rv = card->SetDn(newDN); NS_ENSURE_SUCCESS(rv, rv); // Launch query rv = DoModify(this, nsILDAPModification::MOD_REPLACE, oldDN, modArray, newRDN, baseDN); } return rv; }
NS_IMETHODIMP nsAbQueryLDAPMessageListener::OnLDAPMessage(nsILDAPMessage *aMessage) { nsresult rv; rv = Initiate(); NS_ENSURE_SUCCESS(rv, rv); PRInt32 messageType; rv = aMessage->GetType(&messageType); NS_ENSURE_SUCCESS(rv, rv); PRBool cancelOperation = PR_FALSE; // Enter lock { nsAutoLock lock (mLock); if (mFinished) return NS_OK; if (messageType == nsILDAPMessage::RES_SEARCH_RESULT) mFinished = PR_TRUE; else if (mCanceled) { mFinished = PR_TRUE; cancelOperation = PR_TRUE; } } // Leave lock if (!mDirectoryQuery) return NS_ERROR_NULL_POINTER; nsCOMPtr<nsIAbDirectoryQueryResult> queryResult; if (!cancelOperation) { switch (messageType) { case nsILDAPMessage::RES_BIND: rv = OnLDAPMessageBind (aMessage); NS_ENSURE_SUCCESS(rv, rv); break; case nsILDAPMessage::RES_SEARCH_ENTRY: if (!mFinished && !mWaitingForPrevQueryToFinish) { rv = OnLDAPMessageSearchEntry (aMessage, getter_AddRefs (queryResult)); } break; case nsILDAPMessage::RES_SEARCH_RESULT: mWaitingForPrevQueryToFinish = PR_FALSE; rv = OnLDAPMessageSearchResult (aMessage, getter_AddRefs (queryResult)); NS_ENSURE_SUCCESS(rv, rv); default: break; } } else { if (mSearchOperation) rv = mSearchOperation->AbandonExt (); rv = QueryResultStatus (nsnull, getter_AddRefs (queryResult), nsIAbDirectoryQueryResult::queryResultStopped); // reset because we might re-use this listener...except don't do this // until the search is done, so we'll ignore results from a previous // search. if (messageType == nsILDAPMessage::RES_SEARCH_RESULT) mCanceled = mFinished = PR_FALSE; } if (queryResult && mQueryListener) rv = mQueryListener->OnQueryItem (queryResult); return rv; }
NS_IMETHODIMP nsAbLDAPDirectory::AddCard(nsIAbCard *aUpdatedCard, nsIAbCard **aAddedCard) { NS_ENSURE_ARG_POINTER(aUpdatedCard); NS_ENSURE_ARG_POINTER(aAddedCard); nsCOMPtr<nsIAbLDAPAttributeMap> attrMap; nsresult rv = GetAttributeMap(getter_AddRefs(attrMap)); NS_ENSURE_SUCCESS(rv, rv); // Create a new LDAP card nsCOMPtr<nsIAbLDAPCard> card = do_CreateInstance(NS_ABLDAPCARD_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); rv = Initiate(); NS_ENSURE_SUCCESS(rv, rv); // Copy over the card data nsCOMPtr<nsIAbCard> copyToCard = do_QueryInterface(card, &rv); NS_ENSURE_SUCCESS(rv, rv); rv = copyToCard->Copy(aUpdatedCard); NS_ENSURE_SUCCESS(rv, rv); // Retrieve preferences nsCAutoString prefString; rv = GetRdnAttributes(prefString); NS_ENSURE_SUCCESS(rv, rv); CharPtrArrayGuard rdnAttrs; rv = SplitStringList(prefString, rdnAttrs.GetSizeAddr(), rdnAttrs.GetArrayAddr()); NS_ENSURE_SUCCESS(rv, rv); rv = GetObjectClasses(prefString); NS_ENSURE_SUCCESS(rv, rv); CharPtrArrayGuard objClass; rv = SplitStringList(prefString, objClass.GetSizeAddr(), objClass.GetArrayAddr()); NS_ENSURE_SUCCESS(rv, rv); // Process updates nsCOMPtr<nsIArray> modArray; rv = card->GetLDAPMessageInfo(attrMap, objClass.GetSize(), objClass.GetArray(), nsILDAPModification::MOD_ADD, getter_AddRefs(modArray)); NS_ENSURE_SUCCESS(rv, rv); // For new cards, the base DN is the search base DN nsCOMPtr<nsILDAPURL> currentUrl; rv = GetLDAPURL(getter_AddRefs(currentUrl)); NS_ENSURE_SUCCESS(rv, rv); nsCAutoString baseDN; rv = currentUrl->GetDn(baseDN); NS_ENSURE_SUCCESS(rv, rv); // Calculate DN nsCAutoString cardDN; rv = card->BuildRdn(attrMap, rdnAttrs.GetSize(), rdnAttrs.GetArray(), cardDN); NS_ENSURE_SUCCESS(rv, rv); cardDN.AppendLiteral(","); cardDN.Append(baseDN); rv = card->SetDn(cardDN); NS_ENSURE_SUCCESS(rv, rv); // Launch query rv = DoModify(this, nsILDAPModification::MOD_ADD, cardDN, modArray, EmptyCString(), EmptyCString()); NS_ENSURE_SUCCESS(rv, rv); NS_ADDREF(*aAddedCard = copyToCard); return NS_OK; }
TEST_F(CoreContextTest, InitiateMultipleChildren) { AutoCurrentContext testCtxt; testCtxt->Initiate(); // Initiate all children { auto outerCtxt = testCtxt->Create<void>(); auto child1 = outerCtxt->Create<void>(); auto child2 = outerCtxt->Create<void>(); auto child3 = outerCtxt->Create<void>(); child1->Initiate(); child2->Initiate(); child3->Initiate(); outerCtxt->Initiate(); ASSERT_TRUE(child1->IsRunning()); ASSERT_TRUE(child2->IsRunning()); ASSERT_TRUE(child3->IsRunning()); outerCtxt->SignalShutdown(true); } // Don't initiate middle child { auto outerCtxt = testCtxt->Create<void>(); auto child1 = outerCtxt->Create<void>(); auto child2 = outerCtxt->Create<void>(); auto child3 = outerCtxt->Create<void>(); child1->Initiate(); child3->Initiate(); outerCtxt->Initiate(); ASSERT_TRUE(child1->IsRunning()); ASSERT_FALSE(child2->IsInitiated()); ASSERT_TRUE(child3->IsRunning()); outerCtxt->SignalShutdown(true); } // Don't initiate middle child and initiate parent first { auto outerCtxt = testCtxt->Create<void>(); auto child1 = outerCtxt->Create<void>(); auto child2 = outerCtxt->Create<void>(); auto child3 = outerCtxt->Create<void>(); outerCtxt->Initiate(); child1->Initiate(); child3->Initiate(); ASSERT_TRUE(child1->IsRunning()); ASSERT_FALSE(child2->IsInitiated()); ASSERT_TRUE(child3->IsRunning()); outerCtxt->SignalShutdown(true); } }
InputBufferedStream::InputBufferedStream(IOBasicTypes::LongBufferSizeType inBufferSize) { Initiate(NULL,inBufferSize); }
//----------------------------------------------------------------------------- // Name: WinMain() // Desc: Entry point to the program. Initializes everything and calls //----------------------------------------------------------------------------- int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdline, int nCmdShow) { HWND hWnd; // generic window handle MSG msg; // generic message HDC hDC; // generic dc WNDCLASS winclass; // this will hold the class created bool bDone = false; //fill in the window class stucture winclass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW; winclass.lpfnWndProc = WindowProc; winclass.cbClsExtra = 0; winclass.cbWndExtra = 0; winclass.hInstance = hInstance; winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); winclass.hCursor = LoadCursor(NULL, IDC_ARROW); winclass.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH); winclass.lpszMenuName = NULL; //MAKEINTRESOURCE(IDR_MENU1); winclass.lpszClassName = WINDOW_CLASS_NAME; // register the window class if (!RegisterClass(&winclass)) return(0); // create the window if (!(hWnd = CreateWindow(WINDOW_CLASS_NAME, // class "Bouncing on the desktop", // title WS_POPUP | WS_VISIBLE, 100,100, // x,y WINDOW_WIDTH, // width WINDOW_HEIGHT, // height NULL, // handle to parent NULL, // handle to menu hInstance,// instance NULL))) // creation parms { MessageBox(hWnd, "Window Could not be Created", NULL, MB_OK); //NULL is default for Error return(0); } // save the window handle and instance in a global main_window_handle = hWnd; main_instance = hInstance; //Init everything if( !Initiate() ) { MessageBox(hWnd, cpErrorBuf, "Initiate() Failed", NULL); //NULL is default for Error box return(0); } // enter main event loop while(!bDone) { if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { // test if this is a quit message if (msg.message == WM_QUIT) break; // translate any accelerator keys TranslateMessage(&msg); // send the message to the window proc DispatchMessage(&msg); } // end if bDone = Main(ddsd, lpddsprimary); } // end while if( !Shutdown() ) { MessageBox(hWnd, cpErrorBuf, "Shutdown() Failed" , NULL); //NULL is default for Error box return(0); } // return to Windows like this return(msg.wParam); } // end WinMain
int _tmain(int argc, _TCHAR* argv[]) { //------------------Initate OpenGL --------------- //init glfw if (!glfwInit()) { fprintf(stderr, "Failed to initialize GLFW\n"); return -1; } //Iniate OpenGL using glfw GLFWwindow* window; window = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "Lab2: Heirachy animation", NULL, NULL); if (window == NULL){ fprintf(stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n"); glfwTerminate(); return -1; } glfwMakeContextCurrent(window); // Initialize GLEW glewExperimental = true; // Needed in core profile //Initate glew if (glewInit() != GLEW_OK) { fprintf(stderr, "Failed to initialize GLEW\n"); return -1; } //--end of opengl Initation ------------------- //---initate scene-------------------------- //function to modify scene Initiate(); //--end of scene initation------------ //---OpenGL main Loop------------- // get start time for animation double start_time = glfwGetTime(); //main loop do{ //main double cur_time = glfwGetTime(); double elapse_time = cur_time - start_time; //update main scene --if animation is used Main_Scene.Update(elapse_time); //draw main scene Main_Scene.Draw(); // Swap buffers glfwSwapBuffers(window); glfwPollEvents(); } // Check if the ESC key was pressed or the window was closed while (glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS && glfwWindowShouldClose(window) == 0); //----end of main loop------------------ return 0; }
NS_IMETHODIMP nsAbLDAPDirectory::StartSearch () { if (!mIsQueryURI || mQueryString.IsEmpty()) return NS_OK; nsresult rv = Initiate(); NS_ENSURE_SUCCESS(rv, rv); rv = StopSearch(); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIAbDirectoryQueryArguments> arguments = do_CreateInstance(NS_ABDIRECTORYQUERYARGUMENTS_CONTRACTID,&rv); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIAbBooleanExpression> expression; rv = nsAbQueryStringToExpression::Convert(mQueryString.get(), getter_AddRefs(expression)); NS_ENSURE_SUCCESS(rv, rv); rv = arguments->SetExpression(expression); NS_ENSURE_SUCCESS(rv, rv); rv = arguments->SetQuerySubDirectories(PR_TRUE); NS_ENSURE_SUCCESS(rv, rv); // Get the max hits to return PRInt32 maxHits; rv = GetMaxHits(&maxHits); if (NS_FAILED(rv)) maxHits = kDefaultMaxHits; // get the appropriate ldap attribute map, and pass it in via the // TypeSpecificArgument nsCOMPtr<nsIAbLDAPAttributeMap> attrMap; rv = GetAttributeMap(getter_AddRefs(attrMap)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsISupports> typeSpecificArg = do_QueryInterface(attrMap, &rv); NS_ENSURE_SUCCESS(rv, rv); rv = arguments->SetTypeSpecificArg(attrMap); NS_ENSURE_SUCCESS(rv, rv); if (!mDirectoryQuery) { mDirectoryQuery = do_CreateInstance(NS_ABLDAPDIRECTORYQUERY_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); } // Perform the query rv = mDirectoryQuery->DoQuery(this, arguments, this, maxHits, 0, &mContext); NS_ENSURE_SUCCESS(rv, rv); // Enter lock nsAutoLock lock(mLock); mPerformingQuery = PR_TRUE; mCache.Clear(); return rv; }
InputBufferedStream::InputBufferedStream(void) { Initiate(NULL,DEFAULT_BUFFER_SIZE); }