bool DataObjectListHelper::AddObject( const CString& name, const CString& value )
{
    if( name.GetLength() == 0 || value.GetLength() == 0 ) return false;

    ArxDictTool* pDictTool = ArxDictTool::GetDictTool( OBJECT_LIST_DICT );
    bool ret = ( INVALID_ENTRY != pDictTool->addEntry( name, value ) );
    if( ret )
    {
        ArxDictTool2* pDictTool2 = ArxDictTool2::GetDictTool( OBJECT_LIST_DATA_DICT );
        CString key;
        key.Format( _T( "%s_%s" ), name, value );

        DataObject* pDO = new DataObject();
        pDO->setType( name );
        pDO->initData();  // 初始化数据
        ret = pDictTool2->addEntry( key, pDO );
        if( !ret ) // 添加Object失败
        {
            delete pDO;
            pDictTool->removeEntry( name, value );
        }
        delete pDictTool2;
    }
    delete pDictTool;

    return ret;
}
Example #2
0
Gltx*
ObjectCache::findGltx(Id gltx_id)
{
    DataObject* object = find(gltx_id);
    if (object == NULL) return NULL;

    switch (object->dataType()) {
    case DataObject::CARD_ADJUST:
    case DataObject::CHEQUE:
    case DataObject::CLAIM:
    case DataObject::GENERAL:
    case DataObject::INVOICE:
    case DataObject::ITEM_ADJUST:
    case DataObject::NOSALE:
    case DataObject::PAYOUT:
    case DataObject::RECEIPT:
    case DataObject::RECEIVE:
    case DataObject::RETURN:
    case DataObject::SHIFT:
    case DataObject::TEND_ADJUST:
    case DataObject::WITHDRAW:
	return (Gltx*)object;
    default:
	break;
    }

    qWarning("Invalid gltx type: " + object->dataTypeName());
    return NULL;
}
Example #3
0
int main (int argc, char **argv) {

	if(argc == 2 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))) {
		printf("Usage : ./hashcode.out [input filename] [output filename]\n");
		return -1;
	}

	DataObject *data = new DataObject();
	int status = data->readData(argc == 2 ? argv[1] : "busy_day.in");
	if(status < 0) {
		fprintf(stderr, "readInputFile return %d... expected 0 !\n", status);
		return -2;
	}

	ResultObject *result = new ResultObject();
	process(data, result);
	if(status < 0) {
		fprintf(stderr, "process return %d... expected 0 !\n", status);
		return -3;
	}

	result->writeResult(argc == 3 ? argv[2] : "output.txt");
	if(status < 0) {
		fprintf(stderr, "writeResultFile return %d... expected 0 !\n", status);
		return -4;
	}

	delete data;
	delete result;

	return 0;
}
void
DirEntity::UnpackDataObjects(BaseMessage& theMsgR, DataObjectTypeSet& theSetR,
                             unsigned long theFlags)
{
	WTRACE("DirEntity::UnpackDataObjects");
	unsigned short aCt = theMsgR.ReadShort();
	WDBG_LL("DirEntity::UnpackDataObjects Unpacking data objects, size=" << aCt);
	theSetR.clear();

	bool unpackType = ((theFlags & WONMsg::GF_ADDDOTYPE) != 0);
	bool unpackData = ((theFlags & WONMsg::GF_ADDDODATA) != 0);
	for (int i=0; i < aCt; i++)
	{
		DataObject anObj;
		if (unpackType)
		{
			unsigned char aLen = theMsgR.ReadByte();
			anObj.GetDataType().assign(reinterpret_cast<const unsigned char*>(theMsgR.ReadBytes(aLen)), aLen);
		}
		else
			anObj.GetDataType().assign(reinterpret_cast<const unsigned char*>(&i), sizeof(i));

		if (unpackData)
		{
			unsigned short aLen = theMsgR.ReadShort();
			anObj.GetData().assign(reinterpret_cast<const unsigned char*>(theMsgR.ReadBytes(aLen)), aLen);
		}

		theSetR.insert(anObj);
	}
}
	virtual void Unexecute(const DataObject &object)
	{
		wxASSERT(1 <= object.numItems());

		wxInt32 player = current();

		if(2 <= object.numItems())
		{
			player = object.read<wxInt32>(1);
		}

		//first, determine the tile and corner being built on
		wxInt32 tile, corner;
		boost::tie(tile, corner) = Utility::decodeSel(object.read<wxInt32>());

		PlayerGame &playergame(playerGame(player));

		wxInt32 turn = gameData<wxInt32>(shTurn);

		//now create the settlement object for this player and remove it from 
		//their list
		CornerObjectPtr settlement(CornerObjectPtr(new SettlementObject(
			player, turn, playergame.color(), GetGame(), tile, corner)));
		playergame.removeCornerObject(shSettlements, settlement);

		//add one to the player's stock settlements
		playerGameData<wxInt32>(shStockSettlements, player) += 1;

		// Subtract one point from the player's score.
		RULE.Execute(shRuleAdjustPoints, DataObject(player, -1));
	}
Example #6
0
bool ReportDataHelper::SetObjectDatas( const AcDbObjectId& objId,const AcStringArray& values )
{
	if( objId.isNull() ) return false;

	AcTransaction* pTrans = actrTransactionManager->startTransaction();
	if( pTrans == 0 ) return false;

	AcDbObject* pObj;
	if( Acad::eOk != pTrans->getObject( pObj, objId, AcDb::kForWrite ) )
	{
		actrTransactionManager->abortTransaction();
		return false;
	}
	DataObject* pDO = DataObject::cast( pObj );
	if( pDO == 0 )
	{
		actrTransactionManager->abortTransaction();
		return false;
	}

	pDO->clearAll();
	for(int i = 0;  i < values.length(); i++)
	{
		CString value = values[i].kACharPtr();
		pDO->addData();
		pDO->setData(i,value);
	}
	actrTransactionManager->endTransaction();
	return true;
}
Example #7
0
/******************************************************************************
* This method is called when a reference target changes.
******************************************************************************/
bool FileSourceEditor::referenceEvent(RefTarget* source, ReferenceEvent* event)
{
	if(source == editObject()) {
		if(event->type() == ReferenceEvent::ObjectStatusChanged || event->type() == ReferenceEvent::TitleChanged) {
			updateInformationLabel();
		}
#if 0
		else if(event->type() == ReferenceEvent::ReferenceAdded || event->type() == ReferenceEvent::ReferenceRemoved) {
			ReferenceFieldEvent* refEvent = static_cast<ReferenceFieldEvent*>(event);
			if(refEvent->field() == PROPERTY_FIELD(FileSource::_dataObjects)) {
				DataObject* dataObj = dynamic_object_cast<DataObject>(event->type() == ReferenceEvent::ReferenceAdded ? refEvent->newTarget() : refEvent->oldTarget());
				if(dataObj) {
					if(event->type() == ReferenceEvent::ReferenceAdded) {
						// Open a new sub-editor.
						OORef<PropertiesEditor> subEditor = dataObj->createPropertiesEditor();
						if(subEditor) {
							subEditor->initialize(container(), mainWindow(), _subEditorRolloutParams);
							subEditor->setEditObject(dataObj);
							_subEditors.push_back(subEditor);
						}
					}
					else {
						// Close sub-editor.
						for(int i = (int)_subEditors.size() - 1; i >= 0; i--) {
							if(_subEditors[i]->editObject() == dataObj)
								_subEditors.erase(_subEditors.begin() + i);
						}
					}
				}
			}
		}
#endif
	}
	return PropertiesEditor::referenceEvent(source, event);
}
	virtual void Decide(const DataObject &input, DataObject &output)
	{
		// There are two conditions that must be met in order for a player to
		// be allowed to build a knight:
		// 
		// 1) They must have the resources to activate a knight.
		// 2) They must have at least one inactive knight on the board
		//
		// None of these conditions can be affected by other rulesets.

		bool can = false;
		wxInt32 trades = 0;

		// Condition 1.
		RULE.Decide(shLogicCanPurchaseActivateKnight, input, output);
		wxASSERT(2 <= output.numItems());

		if(true == output.read<bool>())
		{
			trades = output.read<wxInt32>(1);

			// Condition 2.
			output.reset();
			RULE.Decide(shLogicCanPlaceActivateKnight, input, output);

			can = (false == 
				output.read<PlayerGame::CornerObjectArray>().empty());
		}

		output = DataObject(can, trades);
	}
    void test_ClientFilter() {

       	// should fail because there is no session
		CPPUNIT_ASSERT( msdo->addClientFilter("non-existing-id","test1", "test1" ) == false );

		// add a session so the other attribute checks will pass
		CPPUNIT_ASSERT( msdo->addClientAttribute("test-session","test1", "value") == true );
		CPPUNIT_ASSERT( msdo->addClientFilter("test-session","test1", "test1" ) == true );

		// Assert that the value we just inserted is good
		std::map < std::string, std::string > filterList;
		filterList = msdo->getClientFilter("test-session");
		CPPUNIT_ASSERT( filterList.size() == 1 ); // the one we just added
		CPPUNIT_ASSERT( filterList.find("test1") != filterList.end() ); // make sure it exists
		CPPUNIT_ASSERT( filterList["test1"] == "test1" );

		// Add another of the same name, which is effectively an update
		CPPUNIT_ASSERT( msdo->addClientFilter("test-session", "test1", "updated") == true );
		CPPUNIT_ASSERT( msdo->getClientFilter("test-session","test1") == "updated");

		// Remove the object
		msdo->removeClientFilter("test-session", "test1" );

		// Make sure it's gone
		CPPUNIT_ASSERT( msdo->getClientFilter("test-session", "test1" ) == "" );

		// Can't have an empty sessionid or name/key
		CPPUNIT_ASSERT( msdo->addClientAttribute("","key","value") == false );
		CPPUNIT_ASSERT( msdo->addClientAttribute("test-session", "", "value") == false );

    }
Example #10
0
IDataObject* SetClipboard(CLIPFORMAT format, HGLOBAL data)
{
  DataObject* object = new DataObject(format, data);
  uint32 result = OleSetClipboard(object);
  object->Release();
  return SUCCEEDED(result) ? object : NULL;
}
// SMsgDirG2ClearDataObjects::Unpack
// Virtual method from SmallMessage.  Extracts data from message buffer.
void
SMsgDirG2ClearDataObjects::Unpack(void)
{
	WTRACE("SMsgDirG2ClearDataObjects::Unpack");
	mClearTypes.clear();
	mKeyType = (GetMessageType() == WONMsg::DirG2ServiceClearDataObjects ? KT_SERVICE : KT_DIRECTORY);
	SMsgDirG2UpdateBase::Unpack();

	if ((GetServiceType() != WONMsg::SmallDirServerG2) ||
	    ((GetMessageType() != WONMsg::DirG2DirectoryClearDataObjects) &&
	     (GetMessageType() != WONMsg::DirG2ServiceClearDataObjects)))
	{
		WDBG_AH("SMsgDirG2ClearDataObjects::Unpack Not a DirG2ClearDataObjects message!");
		throw WONMsg::BadMsgException(*this, __LINE__, __FILE__,
		                              "Not a DirG2ClearDataObjects message.");
	}

	UnpackKey(*this);
	unsigned short aCt = ReadShort();
	WDBG_LL("SMsgDirG2ClearDataObjects::Unpack Reading " << aCt << " entries.");

	for (int i=0; i < aCt; i++)
	{
		DataObject anObj;
		unsigned char aLen = ReadByte();
		if (aLen > 0)
			anObj.GetDataType().assign(reinterpret_cast<const unsigned char*>(ReadBytes(aLen)), aLen);
		mClearTypes.insert(anObj);
	}

	UnpackPeerData();
}
Example #12
0
DataObject* PowerHandler::GetCaseObject(DataObject* project, const char* case_name)
{
    DataObject* d_case = nullptr;
    DataObjVec folders = Utils::GetChildren(project, "IntPrjfolder");

    DataObjVec::iterator it =  folders.begin();
    for (; it != folders.end(); ++it) {
        DataObject* studyCases = *it;
        ValueGuard name(studyCases->GetName());
        if (!strstr(name->GetString(), "Study Cases")) {
            continue;
        }

        ValueGuard children(studyCases->GetChildren(false));
        for (int i = 0, count = children->VecGetSize(); i < count; ++i) {
             DataObject* child = children->VecGetDataObject(i);
             if (strstr(child->GetName()->GetString(), case_name)) {
                  d_case = child;
                  break;
             }
         }
    }

    return d_case;
}
Example #13
0
void
AutoReleasePool::dispose()
{
    for (DataObject* obj = head; obj != NULL; obj = obj->next) {
        obj->release();
    }
    head = tail = NULL;
}
Example #14
0
IRegistry* DataSvcFileEntriesTool::i_getRootNode() {
  DataObject * obj = 0;
  StatusCode sc = m_dataSvc->retrieveObject(m_rootNode, obj);
  if (sc.isFailure()) {
    throw GaudiException("Cannot get " + m_rootNode + " from " + m_dataSvcName, name(), StatusCode::FAILURE);
  }
  return obj->registry();
}
    void test_ServerAttribute() {

    	// Add an attribute
    	CPPUNIT_ASSERT( msdo->addServerAttribute("test-session","test1", "test1" ) == true );

    	// Assert we have a single attribute
    	CPPUNIT_ASSERT( msdo->getServerSessionCount() == 1 );

    	// Assert that the value we just inserted is good
    	CPPUNIT_ASSERT( msdo->getServerAttribute("test-session", "test1" ) == "test1"  );

    	// Add another of the same name, which is effectively an update
    	CPPUNIT_ASSERT( msdo->addServerAttribute("test-session", "test1", "updated") == true );
    	CPPUNIT_ASSERT( msdo->getServerAttribute("test-session","test1") == "updated");

    	// Remove the object
    	msdo->removeServerAttribute("test-session", "test1" );

    	// Make sure it's gone
    	CPPUNIT_ASSERT( msdo->getServerAttribute("test-session", "test1" ) == "" );

    	// Can't have an empty sessionid or name/key
    	CPPUNIT_ASSERT( msdo->addServerAttribute("","key","value") == false );
    	CPPUNIT_ASSERT( msdo->addServerAttribute("test-session", "", "value") == false );
    }
Example #16
0
void CameraDolly::moveTo(DataObject & dataObject, vtkIdType index, IndexType indexType, bool overTime)
{
    auto dataSet = dataObject.dataSet();

    if (!dataSet)
    {
        qWarning() << "No data found in data object: " << dataObject.name();
        return;
    }

    moveTo(*dataSet, index, indexType, overTime);
}
bool GDESDataObjectHelper::AddObject( const CString& name )
{
    if( name.GetLength() == 0 ) return false;

    ArxDictTool2* pDictTool2 = ArxDictTool2::GetDictTool( REPORTER_INFO_DICT );
    DataObject* pDO = new DataObject();
    pDO->initData();  // 初始化数据
    bool ret = pDictTool2->addEntry( name, pDO );
    if( !ret ) delete pDO; // 添加Object失败
    delete pDictTool2;
    return ret;
}
Example #18
0
bool PropertyDataUpdater::ReadDataFromGE( CMFCPropertyGridCtrl* pPropDataList, const AcDbObjectId& objId )
{
    if( pPropDataList == NULL ) return false;
    if( objId.isNull() ) return false;

    //PrintPropList(pPropDataList);

    // 填充内容
    AcTransaction* pTrans = actrTransactionManager->startTransaction();
    if( pTrans == 0 ) return false;

    AcDbObject* pObj;
    if( Acad::eOk != pTrans->getObject( pObj, objId, AcDb::kForRead ) )
    {
        actrTransactionManager->abortTransaction();
        return false;
    }
    DataObject* pDO = DataObject::cast( pObj );
    if( pDO == 0 )
    {
        actrTransactionManager->abortTransaction();
        return false;
    }

    //acutPrintf(_T("\n读取数据..."));
    DataHelperImpl dh( pDO );
    int nCount = pPropDataList->GetPropertyCount();
    for ( int i = 0; i < nCount; i++ )
    {
        CMFCPropertyGridProperty* pProp = pPropDataList->GetProperty( i );

        CString value;
        dh.getPropertyData( pProp->GetName(), value ); // 更新属性数据

        FieldInfo info; // 默认设置(DT_STRING, m_enable=true, m_descr =_T(""))
        FieldInfoHelper::ReadFieldInfo( pDO->getType(), pProp->GetName(), info );

        SetPropValue( pProp, info, value ); // 设置属性值

		//DATA_TYPE dt       = info.m_dt;
		//LIST_TYPE lt       = info.m_lt;
		//if (dt == DT_LIST && lt == LT_INT)
		//{
		//	
		//}

    }

    actrTransactionManager->endTransaction();
	//PrintPropList(pPropDataList);
    return true;
}
void
SMsgDirG2UpdateExtendBase::UnpackExtended(void)
{
	WTRACE("SMsgDirG2UpdateExtendBase::UnpackExtended");
	WDBG_LL("SMsgDirG2UpdateExtendBase::UnpackExtended enableDataObjects=" << mEnableDataObjects << " enableACLs=" << mEnableACLs);
	mDataObjects.clear();
	mACLs.clear();

	if (mEnableDataObjects)
	{
		unsigned short aCt = ReadShort();
		WDBG_LL("SMsgDirG2UpdateExtendBase::UnpackExtended Reading " << aCt << " data objects.");

		for (int i=0; i < aCt; i++)
		{
			DataObject anObj;
			unsigned char aTypeLen = ReadByte();
			if (aTypeLen > 0)
				anObj.GetDataType().assign(reinterpret_cast<const unsigned char*>(ReadBytes(aTypeLen)), aTypeLen);

			unsigned short aDataLen = ReadShort();
			if (aDataLen > 0)
				anObj.GetData().assign(reinterpret_cast<const unsigned char*>(ReadBytes(aDataLen)), aDataLen);

			mDataObjects.insert(anObj);
		}
	}

	if (mEnableACLs)
	{
		unsigned short aCt = ReadShort();
		WDBG_LL("SMsgDirG2UpdateExtendBase::UnpackExtended Reading " << aCt << " ACLs.");

		for (int i=0; i < aCt; i++)
		{
			DirACL anACL;
			anACL.mType = static_cast<WONMsg::DirG2ACLType>(ReadByte());

			unsigned short aPermCt = ReadShort();
			for (int j=0; j < aPermCt; j++)
			{
				Permission aPerm;
				aPerm.mUserId      = ReadLong();
				aPerm.mCommunityId = ReadLong();
				aPerm.mTrustLevel  = ReadShort();
				anACL.mACL.insert(aPerm);
			}

			mACLs.push_back(anACL);
		}
	}
}
Example #20
0
bool PowerHandler::InitHandler(const char* prj_name, const char* case_name, double sim_time, double sim_period)
{
    _instance = _api_fixture->GetInstance();      //ApiFixture is responsible for creation/destruction api instance
    if (!_instance) {
        //std::cout << "InitHandler, error:ApiFixture::GetInstance()" << std::endl;
        return false;
    }

    int ret = 0;
    Application* app = _instance->GetApplication();
    DataObject* user = app->GetCurrentUser();
    DataObject* prj = GetProject(user, prj_name);
    DataObject* e_case = GetCaseObject(prj, case_name);

    Value v_prj(prj);
    Value v_case(e_case);
    if (prj != app->GetActiveProject()){
        app->Execute("Activate", &v_prj, &ret);                     //激活项目
        if (ret > 0){
            //std::cout << "InitHandler, error: Execute v_prj" << std::endl;
            return false;
        }
    }

    if (e_case != app->GetActiveStudyCase()){
        app->Execute("Activate", &v_case, &ret);//激活项目
        if (ret > 0){
           // std::cout << "InitHandler, error: Execute v_case" << std::endl;
            return false;
        }
    }

    //delete the last EvtParam for no influencing the next simulation
    Value v_ev("IntEvt");
    ValueGuard int_ev(app->Execute("GetCaseObject", &v_ev));
    DataObject* events = int_ev->GetDataObject();
    DataObjVec folders = Utils::GetChildren(events, "EvtParam");

    DataObjVec::iterator it = folders.begin();
    for (; it != folders.end(); ++it) {
        DataObject* folder = *it;
        folder->DeleteObject();
    }

    _sim_time = sim_time;
    _sim_period = sim_period;

    //std::cout << "InitHandler, success." << std::endl;

    return true;
}
    void test_ClientSession() {

    	std::map<std::string, std::string> sess,sess_b;

    	// check for non-existent session
    	CPPUNIT_ASSERT( msdo->clientSessionExists("123123") == false );

    	// add session
    	CPPUNIT_ASSERT( msdo->addClientSession("123123") == true );

    	// check for now existing session
    	CPPUNIT_ASSERT( msdo->clientSessionExists("123123") == true );

    	// try and add the same session, should do an update, not an add
    	CPPUNIT_ASSERT( msdo->addClientSession("123123") == false );

    	// get session, then check that the expected session key exists
    	// and that it matches
    	sess = msdo->getClientSession("123123");
    	CPPUNIT_ASSERT( !sess.empty() );
    	CPPUNIT_ASSERT( sess.find("ip") != sess.end() );
    	CPPUNIT_ASSERT( sess["ip"] == "123123" );

    	// remove session
    	msdo->removeClientSession("123123");

    	// get empty session
    	sess_b = msdo->getClientSession("123123");
    	CPPUNIT_ASSERT( sess_b.empty() );

    	// negative check for session again
    	CPPUNIT_ASSERT( msdo->clientSessionExists("123123") == false );

    }
Example #22
0
DataObject* MainWindow::parseCSVFile(QString dataFileName)
{
    DataObject *dobj = new DataObject();

    // Open the file
    QFile dataFile(dataFileName);

    if (!dataFile.open(QIODevice::ReadOnly | QIODevice::Text))
         return NULL;

    // Create text stream
    QTextStream dataStream(&dataFile);
    QString line;
    QStringList lineValues;
    long long elemid = 0;

    // Get metadata from first line
    line = dataStream.readLine();
    dobj->meta = line.split(',');
    dobj->numDimensions = dobj->meta.size();

    // Get data
    while(!dataStream.atEnd())
    {
        line = dataStream.readLine();
        lineValues = line.split(',');

        if(lineValues.size() != dobj->numDimensions)
        {
            cerr << "ERROR: element dimensions do not match metadata!" << endl;
            cerr << "At element " << elemid << endl;
            return NULL;
        }

        for(int i=0; i<lineValues.size(); i++)
        {
            dobj->vals.push_back(lineValues[i].toDouble());
        }

        elemid++;
    }

    // Close and return
    dataFile.close();

    dobj->init();

    return dobj;
}
Example #23
0
/** IDataManagerSvc: Remove all data objects below the sub tree
 *  identified by its full path name.
 */
StatusCode DataSvc::clearSubTree(const std::string& sub_tree_path)    {
  DataObject* pObject = 0;
  StatusCode status = findObject(sub_tree_path, pObject);
  if ( status.isSuccess() )   {
    RegEntry* node_entry = CAST_REGENTRY(RegEntry*,pObject->registry());
    if ( 0 != node_entry )   {
      RegEntry* parent = node_entry->parentEntry();
      if ( 0 != parent )  {
        parent->remove(node_entry);
        return StatusCode::SUCCESS;
      }
      return INVALID_PARENT;
    }
    return INVALID_OBJECT;
  }
Example #24
0
DataObject* PowerHandler::GetChild(DataObject* object, const char* child_name)
{
    DataObject* d_chi = nullptr;
    const Value* children = object->GetChildren(false);

    for (int i = 0; i < children->VecGetSize(); ++i){
        DataObject* child = children->VecGetDataObject(i);
        if (strcmp(child->GetName()->GetString(), child_name) == 0){
            d_chi = child;
            break;
        }
    }

    return d_chi;
}
Example #25
0
	virtual void Decide(const DataObject &input, DataObject &output)
	{
		// There are three conditions that must be met in order for a player to
		// be allowed to build a city:
		// 
		// 1) They must have at least one city in stock.
		// 2) They must have the resources to purchase a city.
		// 3) They must have a settlement on the board to replace with the 
		//    city.
		//
		// None of these conditions can be affected by other rulesets.

		bool canBuild = false;
		wxInt32 trades = 0;

		// Condition 1.
		if(0 < playerGameData<wxInt32>(shStockCities))
		{
			// Condition 2.
			RULE.Decide(shLogicCanPurchaseCity, input, output);
			wxASSERT(2 <= output.numItems());

			if(true == output.read<bool>())
			{
				trades = output.read<wxInt32>(1);

				// Condition 3.
				canBuild = 
					!(playerGame().getCornerObjects(shSettlements).empty());
			}
		}

		output = DataObject(canBuild, trades);
	}
Example #26
0
//---------------------------- PRIVATE          -----------------------------//
void wxMessageUI::OnUpdate(const DataObject &object)
{
	wxASSERT(2 == object.numItems());
	
	//read the data out of the UI
	wxString message = object.read<wxString>();
	const GamePtr &game = object.read<GamePtr>(1);

	spText->Freeze();
	spText->SetLabel(message);

	//set the label color to be the current player, unless the game has ended,
	//in which case it should be white
	if(shComplete == game->read<HashString>(shState))
	{
		wxColour colour = SKIN.Element(shGameUIText);
		spText->SetForegroundColour(colour);
	}
	else
	{
		ColorType type;
		type = game->playerGame(game->read<wxInt32>(
			shCurrentPlayer)).color();
		spText->SetForegroundColour(ColorInfoData::UIColor(type));
	}

	spText->Thaw();
	spText->Refresh();
}
    bool registerTimer(DataObject<TimerObject>& dot) {
        int fd = dot.get([](const TimerObject& t){ return t._fd; });
#ifdef __linux__
        epoll_event evt {};
        evt.events = EPOLLIN;
        evt.data.fd = fd;

        {
            std::lock_guard<std::mutex> lock(_mtx);
            _notify.insert({ fd, dot });
        }

        if (::epoll_ctl(_epfd, EPOLL_CTL_ADD, fd, &evt) < 0) {
            // Delete it again in the case of error
            {
                std::lock_guard<std::mutex> lock(_mtx);
                _notify.erase(fd);
            }

            Logger::pLOG->error("Epoll control error at TimerObjectReactor.registerTimer: {}", std::strerror(errno));
            return false;
        }
#endif
        return true;
    }
	virtual void Decide(const DataObject &input, DataObject &output)
	{
		wxASSERT(2 <= input.numItems());

		bool valid = true;

		size_t die1 = input.read<size_t>();
		size_t die2 = input.read<size_t>(1);

		if(7 == (die1 + die2))
		{
			wxInt32 turn = gameData<wxInt32>(shTurn);
			wxInt32 players = numPlayers();

			wxInt32 round = ((turn - 1) / players) + 1;
			wxInt32 rounds = gameData<wxInt32>(shNo7Rounds);

			if(rounds >= round)
			{
				valid = false;
			}
		}

		output = DataObject(valid);
	}
Example #29
0
bool Exporter::exportVTKXMLImageData(DataObject & image, const QString & fileName)
{
    auto writer = vtkSmartPointer<vtkXMLImageDataWriter>::New();
    writer->SetInputData(image.dataSet());

    return writeVTKXML(writer, fileName);
}
	virtual void Execute(const DataObject &object)
	{
        // The current player has ended a blocking action.
        RULE.Execute(shRuleEndBlockingAction, DataObject(current()));

		wxASSERT(1 <= object.numItems());

		typedef std::map<HashString, wxInt32> ResourceMap;
		const ResourceMap& map = object.read<ResourceMap>();

		// Read the two dice values.
		const HashString& str1 = map.begin()->first;
		const HashString& str2 = (++map.begin())->first;
		
		wxASSERT(1 == str1.size());
		wxASSERT(4 == str2.size());

		wxInt32 die1 = boost::lexical_cast<wxInt32>(str1);
		wxInt32 die2 = boost::lexical_cast<wxInt32>(str2.at(3));
		
		gameData<wxInt32>(shAlchemistDie1) = die1;
		gameData<wxInt32>(shAlchemistDie2) = die2;

		// The player has now played an Alchemist on their turn.
		playerGameData<wxInt32>(shAlchemist) = TRUE;

		RULE.Execute(shRulePlayProgressCardEnd, DataObject());
	}