当前位置: 首页>>代码示例>>C++>>正文


C++ Operation类代码示例

本文整理汇总了C++中Operation的典型用法代码示例。如果您正苦于以下问题:C++ Operation类的具体用法?C++ Operation怎么用?C++ Operation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Operation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: rdnval_repair

static int
rdnval_repair( BackendDB *be )
{
	slap_overinst *on = (slap_overinst *)be->bd_info;
	void *ctx = ldap_pvt_thread_pool_context();
	Connection conn = { 0 };
	OperationBuffer opbuf;
	Operation *op;
	BackendDB db;
	slap_callback sc = { 0 };
	rdnval_repair_cb_t rcb = { 0 };
	SlapReply rs = { REP_RESULT };
	rdnval_mod_t *rmod;
	int nrepaired = 0;

	connection_fake_init2( &conn, &opbuf, ctx, 0 );
	op = &opbuf.ob_op;

	op->o_tag = LDAP_REQ_SEARCH;
	memset( &op->oq_search, 0, sizeof( op->oq_search ) );

	assert( !BER_BVISNULL( &be->be_nsuffix[ 0 ] ) );

	op->o_bd = select_backend( &be->be_nsuffix[ 0 ], 0 );
	assert( op->o_bd != NULL );
	assert( op->o_bd->be_nsuffix != NULL );

	op->o_req_dn = op->o_bd->be_suffix[ 0 ];
	op->o_req_ndn = op->o_bd->be_nsuffix[ 0 ];

	op->o_dn = op->o_bd->be_rootdn;
	op->o_ndn = op->o_bd->be_rootndn;

	op->ors_scope = LDAP_SCOPE_SUBTREE;
	op->ors_tlimit = SLAP_NO_LIMIT;
	op->ors_slimit = SLAP_NO_LIMIT;
	op->ors_attrs = slap_anlist_no_attrs;

	op->ors_filterstr.bv_len = STRLENOF( "(!(=*))" ) + ad_rdnValue->ad_cname.bv_len;
	op->ors_filterstr.bv_val = op->o_tmpalloc( op->ors_filterstr.bv_len + 1, op->o_tmpmemctx );
	snprintf( op->ors_filterstr.bv_val, op->ors_filterstr.bv_len + 1,
		"(!(%s=*))", ad_rdnValue->ad_cname.bv_val );

	op->ors_filter = str2filter_x( op, op->ors_filterstr.bv_val );
	if ( op->ors_filter == NULL ) {
		rs.sr_err = LDAP_OTHER;
		goto done_search;
	}
	
	op->o_callback = ≻
	sc.sc_response = rdnval_repair_cb;
	sc.sc_private = &rcb;
	rcb.bd = &db;
	db = *be;
	db.bd_info = (BackendInfo *)on;

	(void)op->o_bd->bd_info->bi_op_search( op, &rs );

	op->o_tag = LDAP_REQ_MODIFY;
	sc.sc_response = slap_null_cb;
	sc.sc_private = NULL;
	memset( &op->oq_modify, 0, sizeof( req_modify_s ) );

	for ( rmod = rcb.mods; rmod != NULL; ) {
		rdnval_mod_t *rnext;

		Modifications *mod;
		SlapReply rs2 = { REP_RESULT };

		mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
		mod->sml_flags = SLAP_MOD_INTERNAL;
		mod->sml_op = LDAP_MOD_REPLACE;
		mod->sml_desc = ad_rdnValue;
		mod->sml_type = ad_rdnValue->ad_cname;
		mod->sml_values = rmod->vals;
		mod->sml_nvalues = rmod->nvals;
		mod->sml_numvals = rmod->numvals;
		mod->sml_next = NULL;

		op->o_req_dn = rmod->ndn;
		op->o_req_ndn = rmod->ndn;

		op->orm_modlist = mod;

		op->o_bd->be_modify( op, &rs2 );

		slap_mods_free( op->orm_modlist, 1 );
		if ( rs2.sr_err == LDAP_SUCCESS ) {
			Debug( LDAP_DEBUG_TRACE, "%s: rdnval_repair: entry DN=\"%s\" repaired\n",
				op->o_log_prefix, rmod->ndn.bv_val, 0 );
			nrepaired++;

		} else {
			Debug( LDAP_DEBUG_ANY, "%s: rdnval_repair: entry DN=\"%s\" repair failed (%d)\n",
				op->o_log_prefix, rmod->ndn.bv_val, rs2.sr_err );
		}

		rnext = rmod->next;
		op->o_tmpfree( rmod, op->o_tmpmemctx );
		rmod = rnext;
//.........这里部分代码省略.........
开发者ID:cptaffe,项目名称:openldap,代码行数:101,代码来源:rdnval.c

示例2: send

/// \brief Send an operation to the server from this avatar
///
/// @param op Operation to be sent
void CharacterClient::send(const Operation & op)
{
    op->setFrom(getId());
    m_connection.send(op);
}
开发者ID:olekw,项目名称:cyphesis,代码行数:8,代码来源:CharacterClient.cpp

示例3: sendAndWaitReply

/// \brief Send an operation to the server, and wait for a reply
///
/// Reply is identified as it should have its refno attribute set to
/// the serialno of the operation sent.
/// @param op Operation to be sent
/// @param res Result with correct refno is returned here
int CharacterClient::sendAndWaitReply(const Operation & op, OpVector & res)
{
    op->setFrom(getId());
    return m_connection.sendAndWaitReply(op, res);
}
开发者ID:olekw,项目名称:cyphesis,代码行数:11,代码来源:CharacterClient.cpp

示例4: callOperation

/// \brief Find and call the handler for an operation
///
/// @param op The operation to be processed.
/// @param res The result of the operation is returned here.
void Entity::callOperation(const Operation & op, OpVector & res)
{
    auto op_no = op->getClassNo();
    OP_SWITCH(op, op_no, res,)
}
开发者ID:cyclefusion,项目名称:cyphesis,代码行数:9,代码来源:Entity.cpp

示例5: AddScalars

bool Sum::CombineLikeOperands( void )
{
	for( OperandList::Node* nodeA = operandList->Head(); nodeA; nodeA = nodeA->Next() )
	{
		Operand* operandA = nodeA->data;

		for( OperandList::Node* nodeB = nodeA->Next(); nodeB; nodeB = nodeB->Next() )
		{
			Operand* operandB = nodeB->data;

			if( operandA->IsScalar() && operandB->IsScalar() )
			{
				Operand* scalar = AddScalars( operandA, operandB );
				if( scalar )
				{
					operandList->InsertAfter()->data = scalar;
					operandList->Remove( nodeA );
					operandList->Remove( nodeB );
					return true;
				}
			}
			else if( dynamic_cast< Vector* >( operandA ) && dynamic_cast< Vector* >( operandB ) )
			{
				Vector* vectorA = ( Vector* )operandA;
				Vector* vectorB = ( Vector* )operandB;

				if( 0 == strcmp( vectorA->GetName(), vectorB->GetName() ) )
				{
					Operand* scalarA = vectorA->GetScalar();
					Operand* scalarB = vectorB->GetScalar();

					vectorA->SetScalar( 0, false );
					vectorB->SetScalar( 0, false );

					if( !scalarA )
					{
						NumericScalar* numericScalar = new NumericScalar();
						numericScalar->SetReal( 1.0 );
						scalarA = numericScalar;
					}

					if( !scalarB )
					{
						NumericScalar* numericScalar = new NumericScalar();
						numericScalar->SetReal( 1.0 );
						scalarB = numericScalar;
					}

					Sum* scalar = new Sum();
					scalar->operandList->InsertAfter()->data = scalarA;
					scalar->operandList->InsertAfter()->data = scalarB;

					vectorB->SetScalar( scalar );
					operandList->Remove( nodeA );

					return true;
				}
			}
			else if( ( operandA->IsBlade() && operandB->IsBlade() ) ||
					( operandA->IsVersor() && operandB->IsVersor() ) )
			{
				Operation* operationA = ( Operation* )operandA;
				Operation* operationB = ( Operation* )operandB;

				if( OperationsAlike( operationA, operationB ) )
				{
					// Degenerates are removed well before we can get here, so this shouldn't happen.
					Vector* vector = operationB->FindLeadingVector();
					if( !vector )
					{
						Error* error = new Error();
						error->Format( "Sum expected to find a leading vector, but didn't." );
						throw error;
					}

					// An empty geometric product in either case will do fine.
					GeometricProduct* scalarA = operationA->StripScalars();
					GeometricProduct* scalarB = operationB->StripScalars();

					Sum* scalar = new Sum();
					scalar->operandList->InsertAfter()->data = scalarA;
					scalar->operandList->InsertAfter()->data = scalarB;

					vector->MarryWithScalar( scalar );
					operandList->Remove( nodeA );

					return true;
				}
			}
		}
	}

	return false;
}
开发者ID:spencerparkin,项目名称:Junk,代码行数:94,代码来源:Sum.cpp

示例6: dds_count

/* count dynamic objects existing in the database at startup */
static int
dds_count( void *ctx, BackendDB *be )
{
	slap_overinst	*on = (slap_overinst *)be->bd_info;
	dds_info_t	*di = (dds_info_t *)on->on_bi.bi_private;

	Connection	conn = { 0 };
	OperationBuffer opbuf;
	Operation	*op;
	slap_callback	sc = { 0 };
	SlapReply	rs = { REP_RESULT };

	int		rc;
	char		*extra = "";

	connection_fake_init( &conn, &opbuf, ctx );
	op = &opbuf.ob_op;

	op->o_tag = LDAP_REQ_SEARCH;
	memset( &op->oq_search, 0, sizeof( op->oq_search ) );

	op->o_bd = be;

	op->o_req_dn = op->o_bd->be_suffix[ 0 ];
	op->o_req_ndn = op->o_bd->be_nsuffix[ 0 ];

	op->o_dn = op->o_bd->be_rootdn;
	op->o_ndn = op->o_bd->be_rootndn;

	op->ors_scope = LDAP_SCOPE_SUBTREE;
	op->ors_tlimit = SLAP_NO_LIMIT;
	op->ors_slimit = SLAP_NO_LIMIT;
	op->ors_attrs = slap_anlist_no_attrs;

	op->ors_filterstr.bv_len = STRLENOF( "(objectClass=" ")" )
		+ slap_schema.si_oc_dynamicObject->soc_cname.bv_len;
	op->ors_filterstr.bv_val = op->o_tmpalloc( op->ors_filterstr.bv_len + 1, op->o_tmpmemctx );
	snprintf( op->ors_filterstr.bv_val, op->ors_filterstr.bv_len + 1,
		"(objectClass=%s)",
		slap_schema.si_oc_dynamicObject->soc_cname.bv_val );

	op->ors_filter = str2filter_x( op, op->ors_filterstr.bv_val );
	if ( op->ors_filter == NULL ) {
		rs.sr_err = LDAP_OTHER;
		goto done_search;
	}

	op->o_callback = &sc;
	sc.sc_response = dds_count_cb;
	sc.sc_private = &di->di_num_dynamicObjects;
	di->di_num_dynamicObjects = 0;

	op->o_bd->bd_info = (BackendInfo *)on->on_info;
	(void)op->o_bd->bd_info->bi_op_search( op, &rs );
	op->o_bd->bd_info = (BackendInfo *)on;

done_search:;
	op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
	filter_free_x( op, op->ors_filter, 1 );

	rc = rs.sr_err;
	switch ( rs.sr_err ) {
	case LDAP_SUCCESS:
		Log1( LDAP_DEBUG_STATS, LDAP_LEVEL_INFO,
			"DDS non-expired=%d\n",
			di->di_num_dynamicObjects );
		break;

	case LDAP_NO_SUCH_OBJECT:
		/* (ITS#5267) database not created yet? */
		rs.sr_err = LDAP_SUCCESS;
		extra = " (ignored)";
		/* fallthru */

	default:
		Log2( LDAP_DEBUG_ANY, LDAP_LEVEL_ERR,
			"DDS non-expired objects lookup failed err=%d%s\n",
			rc, extra );
		break;
	}

	return rs.sr_err;
}
开发者ID:bhanug,项目名称:likewise-open,代码行数:84,代码来源:dds.c

示例7: while

void Server::listen()
{
    while (true)
    {
        Socket new_server_socket;

        cout << "Wait for input..." << endl;

        this->socket.accept(new_server_socket);

        cout << "accept new socket." << endl;

        string recv_cmd;
        bool recv_return = new_server_socket.recv(recv_cmd);
        if (!recv_return)
        {
            cerr << "receive command from client error. @Server::listen" << endl;
            continue;
        }

        cout <<"received msg: " << recv_cmd << endl;

        Operation operation;
        bool parser_return = this->parser(recv_cmd, operation);
        cout << "parser_return=" << parser_return << endl; //debug
        if (!parser_return)
        {
            cout << "parser command error. @Server::listen" << endl;
            string ret_msg = "invalid command.";
            this->response(new_server_socket, ret_msg);
            new_server_socket.close();
            continue;
        }

        string ret_msg;
        CommandType cmd_type = operation.getCommand();
        switch (cmd_type)
        {
        case CMD_LOAD:
        {
            string db_name = operation.getParameter(0);
            this->loadDatabase(db_name, "", ret_msg);
            break;
        }
        case CMD_UNLOAD:
        {
            string db_name = operation.getParameter(0);
            this->unloadDatabase(db_name, "", ret_msg);
            break;
        }
        case CMD_IMPORT:
        {
            string db_name = operation.getParameter(0);
            string rdf_path = operation.getParameter(1);
            this->importRDF(db_name, "", rdf_path, ret_msg);
            break;
        }
        case CMD_QUERY:
        {
            string query = operation.getParameter(0);
            this->query(query, ret_msg);
            break;
        }
        case CMD_SHOW:
        {
            string para = operation.getParameter(0);
            if (para == "databases")
            {
                this->showDatabases("", ret_msg);
            }
            else
            {
                ret_msg = "invalid command.";
            }
            break;
        }
        case CMD_INSERT:
        {
            string db_name = operation.getParameter(0);
            string rdf_path = operation.getParameter(1);
            this->insertTriple(db_name, "", rdf_path, ret_msg);
            break;
        }
        default:
            cerr << "this command is not supported by now. @Server::listen" << endl;
        }

        this->response(new_server_socket, ret_msg);
        new_server_socket.close();
    }
}
开发者ID:zouleipku,项目名称:gStore,代码行数:91,代码来源:Server.cpp

示例8: main

int main(int argc, char *argv[])
{
	ListContainer list_container;
	StackContainer stack_container;
	TimeComplexity time_complexity;				   //TODO: ensure that the below sharing of the same list_container does not interfere with the stack or arithmetic infix to postfix conversions.
	time_complexity.all_lists = &list_container; //gives the TimeComplexity object an address to the listContainer
	stack_container.all_lists = &list_container; //gives the stackContainer an address to the listContainer
/* 
	time_actual = 0;
	
	list_container.initialize("A", "A20.txt");
	ListNode* list = list_container.find_list("A");
	int n_hi = list_container.getN("A");
	int estimate = (n_hi*(6*n_hi))+ 9;
	cout << estimate << " ESTIMATE " << endl;
	list->list.alphabetize();
	cout << time_actual << endl;
	list->list.output();
	return 99; */
	if ( argc != 2 )
	{
		list_container.error("No file input or too many arguments, please try again");
		return -1;
	}
	ArgumentManager argMgr(argv[1]);
	string filename = argMgr.get("script");
	time_complexity.result_filename = argMgr.get("result");
	time_complexity.output("L1,L2,,,,-----,---,O(g(n)),--------,,", "");
	time_complexity.output("size,size,operation,T(n) estimate,T(n) actual,c,n0,g(n)=n^2", "append");
	
	char* fn = new char[filename.length()+1];
	strcpy(fn, filename.c_str());
	
	ifstream fin(fn);
	if(fin.fail())
	{
		list_container.error("Failure to open script file "+filename+" exiting program...");
		return -1;
	}
	
	list_container.error("||||||||||||| Start log for script file "+filename+" |||||||||||||");
	
	OperationQueue opQueue(filename);
	
	while(!opQueue.isEmpty())
	{
		Operation op = opQueue.pop();
		//cout << op << endl;
		if(op.isExpression())	//if true, operation is an expression that needs to be evaluated
		{
			stack_container.convertToPostfix(op.getExpression()); //convert infix to postfix
			stack_container.postfixCalc(op.getName()); //calculte the postfix expression and perform the operations
		}
		else if(op.getName() == "write" || op.getName() == "read")			//if false, the operation could be a simple read or write
		{
			if(op.getName() == "write")
			{	
				if(op.parameterCount() == 2)	//this means there is no 'forward' or 'reverse' specification in which we will just assume forward
				{
					list_container.writeForward(op.getParameter(0), op.getParameter(1));
				}
				else if(op.getParameter(2) == "forward")
				{
					list_container.writeForward(op.getParameter(0), op.getParameter(1));
				}
				else if(op.getParameter(2) == "reverse")
				{	
					list_container.writeReverse(op.getParameter(0), op.getParameter(1));
				}
				else
				{
					list_container.writeForward(op.getParameter(0), op.getParameter(1));
				}
				continue;
			}
			
			if(op.getName() == "read")
			{
				list_container.initialize(op.getParameter(0), op.getParameter(1));
				continue;
			}
		}
		else if(op.getName() == "union" || op.getName() == "intersection") //if not expression or read/write, it must be a union or intersection command
		{
			if(op.getName() == "union")
			{
				// call time complex func, and union here using op.getParameter(0) 1 and 2
				time_complexity.union_tracktime(op.getParameter(0), op.getParameter(1), op.getParameter(2));
				continue;
			}
			else if(op.getName() == "intersection")
			{
				// call time complex func, and intersection here using op.getParameter(0) 1 and 2
				time_complexity.intersection_tracktime(op.getParameter(0), op.getParameter(1), op.getParameter(2));
				continue;
			}
		}
		else
			list_container.error("operation is neither an expression, read/write, or union/intersection and therefore invalid");
	}
//.........这里部分代码省略.........
开发者ID:smtheard,项目名称:Undergrad_Projects,代码行数:101,代码来源:complexity.cpp

示例9: TEST_F

TEST_F(LogStateTest, Diff)
{
  Future<Variable<Slaves>> future1 = state->fetch<Slaves>("slaves");
  AWAIT_READY(future1);

  Variable<Slaves> variable = future1.get();

  Slaves slaves = variable.get();
  ASSERT_EQ(0, slaves.slaves().size());

  for (size_t i = 0; i < 1024; i++) {
    Slave* slave = slaves.add_slaves();
    slave->mutable_info()->set_hostname("localhost" + stringify(i));
  }

  variable = variable.mutate(slaves);

  Future<Option<Variable<Slaves>>> future2 = state->store(variable);
  AWAIT_READY(future2);
  ASSERT_SOME(future2.get());

  variable = future2.get().get();

  Slave* slave = slaves.add_slaves();
  slave->mutable_info()->set_hostname("localhost1024");

  variable = variable.mutate(slaves);

  future2 = state->store(variable);
  AWAIT_READY(future2);
  ASSERT_SOME(future2.get());

  // It's possible that we're doing truncation asynchronously which
  // will cause the test to fail because we'll end up getting a
  // pending position from Log::Reader::ending which will cause
  // Log::Reader::read to fail. To remedy this, we pause the clock and
  // wait for all executing processe to settle.
  Clock::pause();
  Clock::settle();
  Clock::resume();

  Log::Reader reader(log);

  Future<Log::Position> beginning = reader.beginning();
  Future<Log::Position> ending = reader.ending();

  AWAIT_READY(beginning);
  AWAIT_READY(ending);

  Future<list<Log::Entry>> entries = reader.read(beginning.get(), ending.get());

  AWAIT_READY(entries);

  // Convert each Log::Entry to an Operation.
  vector<Operation> operations;

  foreach (const Log::Entry& entry, entries.get()) {
    // Parse the Operation from the Log::Entry.
    Operation operation;

    google::protobuf::io::ArrayInputStream stream(
        entry.data.data(),
        entry.data.size());

    ASSERT_TRUE(operation.ParseFromZeroCopyStream(&stream));

    operations.push_back(operation);
  }

  ASSERT_EQ(2u, operations.size());
  EXPECT_EQ(Operation::SNAPSHOT, operations[0].type());
  EXPECT_EQ(Operation::DIFF, operations[1].type());
}
开发者ID:AbheekG,项目名称:mesos,代码行数:73,代码来源:state_tests.cpp

示例10: main

int main()
{
    {
        Juncture * j = new Juncture(0, "1", 1);

        delete j;
    }

    {
        Juncture * j = new Juncture(0, "1", 1);

        OpVector res;
        Operation op;
        j->operation(op, res);

        delete j;
    }

    {
        Juncture * j = new Juncture(0, "1", 1);

        OpVector res;
        Atlas::Objects::Operation::Login op;
        j->operation(op, res);

        delete j;
    }

    // Login op, no args
    {
        Juncture * j = new Juncture(0, "1", 1);

        OpVector res;
        Operation op;
        j->LoginOperation(op, res);

        delete j;
    }

    // Login op, empty arg
    {
        Juncture * j = new Juncture(0, "1", 1);

        OpVector res;

        Operation op;
        Atlas::Objects::Root arg;
        op->setArgs1(arg);
        
        j->LoginOperation(op, res);

        delete j;
    }

    // Login op, username in arg
    {
        Juncture * j = new Juncture(0, "1", 1);

        OpVector res;

        Operation op;
        Atlas::Objects::Root arg;
        arg->setAttr("username", "69e362c6-03a4-11e0-9608-001ec93e7c08");
        op->setArgs1(arg);
        
        j->LoginOperation(op, res);

        delete j;
    }

    // Login op, bad username in arg
    {
        Juncture * j = new Juncture(0, "1", 1);

        OpVector res;

        Operation op;
        Atlas::Objects::Root arg;
        arg->setAttr("username", 0x69e362c6);
        op->setArgs1(arg);
        
        j->LoginOperation(op, res);

        delete j;
    }

    // Login op, username & password in arg
    {
        Juncture * j = new Juncture(0, "1", 1);

        OpVector res;

        Operation op;
        Atlas::Objects::Root arg;
        arg->setAttr("username", "69e362c6-03a4-11e0-9608-001ec93e7c08");
        arg->setAttr("password", "a12a2f3a-03a4-11e0-8379-001ec93e7c08");
        op->setArgs1(arg);
        
        j->LoginOperation(op, res);

//.........这里部分代码省略.........
开发者ID:worldforge,项目名称:cyphesis,代码行数:101,代码来源:JunctureTest.cpp

示例11: pguid_repair

static int
pguid_repair( BackendDB *be )
{
	slap_overinst *on = (slap_overinst *)be->bd_info;
	void *ctx = ldap_pvt_thread_pool_context();
	Connection conn = { 0 };
	OperationBuffer opbuf;
	Operation *op;
	slap_callback sc = { 0 };
	pguid_repair_cb_t pcb = { 0 };
	SlapReply rs = { REP_RESULT };
	pguid_mod_t *pmod;
	int nrepaired = 0;

	connection_fake_init2( &conn, &opbuf, ctx, 0 );
	op = &opbuf.ob_op;

	op->o_tag = LDAP_REQ_SEARCH;
	memset( &op->oq_search, 0, sizeof( op->oq_search ) );

	op->o_bd = select_backend( &be->be_nsuffix[ 0 ], 0 );

	op->o_req_dn = op->o_bd->be_suffix[ 0 ];
	op->o_req_ndn = op->o_bd->be_nsuffix[ 0 ];

	op->o_dn = op->o_bd->be_rootdn;
	op->o_ndn = op->o_bd->be_rootndn;

	op->ors_scope = LDAP_SCOPE_SUBORDINATE;
	op->ors_tlimit = SLAP_NO_LIMIT;
	op->ors_slimit = SLAP_NO_LIMIT;
	op->ors_attrs = slap_anlist_no_attrs;

	op->ors_filterstr.bv_len = STRLENOF( "(!(=*))" ) + ad_parentUUID->ad_cname.bv_len;
	op->ors_filterstr.bv_val = op->o_tmpalloc( op->ors_filterstr.bv_len + 1, op->o_tmpmemctx );
	snprintf( op->ors_filterstr.bv_val, op->ors_filterstr.bv_len + 1,
		"(!(%s=*))", ad_parentUUID->ad_cname.bv_val );

	op->ors_filter = str2filter_x( op, op->ors_filterstr.bv_val );
	if ( op->ors_filter == NULL ) {
		rs.sr_err = LDAP_OTHER;
		goto done_search;
	}
	
	op->o_callback = &sc;
	sc.sc_response = pguid_repair_cb;
	sc.sc_private = &pcb;
	pcb.on = on;

	(void)op->o_bd->bd_info->bi_op_search( op, &rs );

	op->o_tag = LDAP_REQ_MODIFY;
	sc.sc_response = slap_null_cb;
	sc.sc_private = NULL;
	memset( &op->oq_modify, 0, sizeof( req_modify_s ) );

	for ( pmod = pcb.mods; pmod != NULL; ) {
		pguid_mod_t *pnext;

		Modifications *mod;
		SlapReply rs2 = { REP_RESULT };

		mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
		mod->sml_flags = SLAP_MOD_INTERNAL;
		mod->sml_op = LDAP_MOD_REPLACE;
		mod->sml_desc = ad_parentUUID;
		mod->sml_type = ad_parentUUID->ad_cname;
		mod->sml_values = ch_malloc( sizeof( struct berval ) * 2 );
		mod->sml_nvalues = NULL;
		mod->sml_numvals = 1;
		mod->sml_next = NULL;

		ber_dupbv( &mod->sml_values[0], &pmod->pguid );
		BER_BVZERO( &mod->sml_values[1] );

		op->o_req_dn = pmod->ndn;
		op->o_req_ndn = pmod->ndn;

		op->orm_modlist = mod;
		op->o_bd->be_modify( op, &rs2 );
		slap_mods_free( op->orm_modlist, 1 );
		if ( rs2.sr_err == LDAP_SUCCESS ) {
			Debug( LDAP_DEBUG_TRACE, "%s: pguid_repair: entry DN=\"%s\" repaired\n",
				op->o_log_prefix, pmod->ndn.bv_val, 0 );
			nrepaired++;

		} else {
			Debug( LDAP_DEBUG_ANY, "%s: pguid_repair: entry DN=\"%s\" repair failed (%d)\n",
				op->o_log_prefix, pmod->ndn.bv_val, rs2.sr_err );
		}

		pnext = pmod->next;
		op->o_tmpfree( pmod, op->o_tmpmemctx );
		pmod = pnext;
	}

done_search:;
	op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
	filter_free_x( op, op->ors_filter, 1 );

//.........这里部分代码省略.........
开发者ID:DanahBlanahaseth,项目名称:cniiag_ldap,代码行数:101,代码来源:pguid.c

示例12: sightCreateOperation

/// \brief Process the Sight of a Create operation.
///
/// @param op The Create operation to be processed.
/// @param res The result of the operation is returned here.
void BaseMind::sightCreateOperation(const Operation & op, OpVector & res)
{
    const std::vector<Root> & args = op->getArgs();
    if (args.empty()) {
        debug( std::cout << " no args!" << std::endl << std::flush;);
开发者ID:anthonypesce,项目名称:cyphesis,代码行数:9,代码来源:BaseMind.cpp

示例13: defined

void OperationQueue::runOperations()
{
#if defined(__ANDROID) || defined(ANDROID)
    androidSetupThread();
#endif

    MCLog("start thread");
    mailsem_up(mStartSem);
    
    while (true) {
        Operation * op = NULL;
        bool needsCheckRunning = false;
        bool quitting;
        
        AutoreleasePool * pool = new AutoreleasePool();
        
        mailsem_down(mOperationSem);
        
        pthread_mutex_lock(&mLock);
        if (mOperations->count() > 0) {
            op = (Operation *) mOperations->objectAtIndex(0);
        }
        quitting = mQuitting;
        pthread_mutex_unlock(&mLock);

        //MCLog("quitting %i %p", mQuitting, op);
        if ((op == NULL) && quitting) {
            MCLog("stopping %p", this);
            mailsem_up(mStopSem);
            
            retain(); // (2)
#if __APPLE__
            performMethodOnDispatchQueue((Object::Method) &OperationQueue::stoppedOnMainThread, NULL, mDispatchQueue, true);
#else
            performMethodOnMainThread((Object::Method) &OperationQueue::stoppedOnMainThread, NULL, true);
#endif
            
            pool->release();
            break;
        }

        MCAssert(op != NULL);
        performOnCallbackThread(op, (Object::Method) &OperationQueue::beforeMain, op, true);
        
        if (!op->isCancelled() || op->shouldRunWhenCancelled()) {
            op->main();
        }
        
        op->retain()->autorelease();
        
        pthread_mutex_lock(&mLock);
        mOperations->removeObjectAtIndex(0);
        if (mOperations->count() == 0) {
            if (mWaiting) {
                mailsem_up(mWaitingFinishedSem);
            }
            needsCheckRunning = true;
        }
        pthread_mutex_unlock(&mLock);
        
        if (!op->isCancelled()) {
            performOnCallbackThread(op, (Object::Method) &OperationQueue::callbackOnMainThread, op, true);
        }
        
        if (needsCheckRunning) {
            retain(); // (1)
            //MCLog("check running %p", this);
#if __APPLE__
            performMethodOnDispatchQueue((Object::Method) &OperationQueue::checkRunningOnMainThread, this, mDispatchQueue);
#else
            performMethodOnMainThread((Object::Method) &OperationQueue::checkRunningOnMainThread, this);
#endif
        }
        
        pool->release();
    }
    MCLog("cleanup thread %p", this);
#if defined(__ANDROID) || defined(ANDROID)
    androidUnsetupThread();
#endif
}
开发者ID:AabanTariq,项目名称:UCLA,代码行数:81,代码来源:MCOperationQueue.cpp

示例14: slapi_int_connection_done_pb

void
slapi_int_connection_done_pb( Slapi_PBlock *pb )
{
	Connection		*conn;
	Operation		*op;

	PBLOCK_ASSERT_INTOP( pb, 0 );

	conn = pb->pb_conn;
	op = pb->pb_op;

	/* free allocated DNs */
	if ( !BER_BVISNULL( &op->o_dn ) )
		op->o_tmpfree( op->o_dn.bv_val, op->o_tmpmemctx );
	if ( !BER_BVISNULL( &op->o_ndn ) )
		op->o_tmpfree( op->o_ndn.bv_val, op->o_tmpmemctx );

	if ( !BER_BVISNULL( &op->o_req_dn ) )
		op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
	if ( !BER_BVISNULL( &op->o_req_ndn ) )
		op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );

	switch ( op->o_tag ) {
	case LDAP_REQ_MODRDN:
		if ( !BER_BVISNULL( &op->orr_newrdn ))
			op->o_tmpfree( op->orr_newrdn.bv_val, op->o_tmpmemctx );
		if ( !BER_BVISNULL( &op->orr_nnewrdn ))
			op->o_tmpfree( op->orr_nnewrdn.bv_val, op->o_tmpmemctx );
		if ( op->orr_newSup != NULL ) {
			assert( !BER_BVISNULL( op->orr_newSup ) );
			op->o_tmpfree( op->orr_newSup->bv_val, op->o_tmpmemctx );
			op->o_tmpfree( op->orr_newSup, op->o_tmpmemctx );
		}
		if ( op->orr_nnewSup != NULL ) {
			assert( !BER_BVISNULL( op->orr_nnewSup ) );
			op->o_tmpfree( op->orr_nnewSup->bv_val, op->o_tmpmemctx );
			op->o_tmpfree( op->orr_nnewSup, op->o_tmpmemctx );
		}
		slap_mods_free( op->orr_modlist, 1 );
		break;
	case LDAP_REQ_ADD:
		slap_mods_free( op->ora_modlist, 0 );
		break;
	case LDAP_REQ_MODIFY:
		slap_mods_free( op->orm_modlist, 1 );
		break;
	case LDAP_REQ_SEARCH:
		if ( op->ors_attrs != NULL ) {
			op->o_tmpfree( op->ors_attrs, op->o_tmpmemctx );
			op->ors_attrs = NULL;
		}
		break;
	default:
		break;
	}

	slapi_ch_free_string( &conn->c_authmech.bv_val );
	slapi_ch_free_string( &conn->c_dn.bv_val );
	slapi_ch_free_string( &conn->c_ndn.bv_val );
	slapi_ch_free_string( &conn->c_peer_domain.bv_val );
	slapi_ch_free_string( &conn->c_peer_name.bv_val );

	if ( conn->c_sb != NULL ) {
		ber_sockbuf_free( conn->c_sb );
	}

	slapi_int_free_object_extensions( SLAPI_X_EXT_OPERATION, op );
	slapi_int_free_object_extensions( SLAPI_X_EXT_CONNECTION, conn );

	slapi_ch_free( (void **)&pb->pb_op->o_callback );
	slapi_ch_free( (void **)&pb->pb_op );
	slapi_ch_free( (void **)&pb->pb_conn );
	slapi_ch_free( (void **)&pb->pb_rs );
}
开发者ID:bagel,项目名称:openldap-ga,代码行数:74,代码来源:slapi_ops.c

示例15: executeProgram

void Simulator::executeProgram( Program *program )
{
    int pid = program->process_control_block().processID;
    Operation* operation = program->step();
    char operationType = operation->parameters().id;

    // Create thread lambda
    auto ThreadStart = [this, operation, pid]()
    {
        handleIO(*operation, pid);
    };

    program->run();

    // Start
    if( operationType == 'A' &&
            operation->parameters().description == "start")
    {
        display("OS: starting process " + to_string(pid));
        operation = program->step();
    }

    // I/O
    if( operationType == 'I' || operationType == 'O')
    {
        display("Process: " + to_string(pid) + ": starting I/O");
        thread IO_thread(ThreadStart);
        IO_thread.detach(); // async, do not block

        program->suspend();
        suspendedPrograms_[pid] = *program;
    }

    // Processing
    else if( operationType == 'P' )
    {
        display("Process " + to_string(pid) + ": processing action");
        int quantum = 0;
        while( !operation->completed() && interrupts_.empty() )
        {
            quantum++;

            operation = program->step();
            wait( operation->parameters().cycleTime );

            if( quantum == configurationData.quantum )
            {
                // Launch a quantum interrupt to stop execution of the program
                interrupts_.push(0);
                display("Interrupt: quantum expired");
            }
        }

        if( operation->completed() )
        {
            display("Process " + to_string(pid) + ": end processing action");
        }
    }

    // The last operation in a program is an exit operation
    if( program->operations_left() <= 1 &&
            program->process_control_block().state != SUSPENDED)
    {
        program->exit();
        display("OS: removing process " + to_string(pid));
    }
}
开发者ID:matthewjberger,项目名称:cs446Berger,代码行数:67,代码来源:Simulator.cpp


注:本文中的Operation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。