Exemplo n.º 1
0
void DataSignal :: CreateInitializationData (int scope) {

	int size = SmartMessage::GetSizeOfArrayForScope (scope);
	int i;
	SmartMessage* msg;
	delete[] InitialMatrix;
	InitialMatrix = new bool [size];

	for (i=0; i<size; i++) {

		msg = SmartMessage::GetSmartMessageForScopeAndElement (scope, i);

		if (msg != NULL)
			InitialMatrix [i] = msg->GetInitialValue ();
	}
}
Exemplo n.º 2
0
void DataSignal :: SetMessageValue (int scope, int location, bool value) {

	int myScope = GetObjectScope ();

	if (myScope == scope) {

		SmartMessage* msg = SmartMessage::GetSmartMessageForScopeAndElement (scope, location);
		msg->SetMessageValue (mMessageArray, mValueArray, location, value);

		if (value) {

			bool call = msg->EvaluateCall (mMessageArray);

			if (!call)
				mDoNotCall = true;
		}
	}
}
Exemplo n.º 3
0
void DataSignal :: SetMessageValue (int scope, int location, bool value, bool useVirtualMethod) {

	if (useVirtualMethod)
		SetMessageValue (scope, location, value);

	else if (scope == GetObjectScope ()) {

		mMessageArray [location] = value;

		if (value) {

			SmartMessage* msg = SmartMessage::GetSmartMessageForScopeAndElement (scope, location);
			bool call = msg->EvaluateCall (mMessageArray);

			if (!call)
				mDoNotCall = true;
		}
	}
}
Exemplo n.º 4
0
void DataSignal :: SetMessageValue (const SmartNotice& notice, bool value) {

	int scope = GetObjectScope ();

	if (notice.GetScope () == scope) {

		int index = notice.GetMessageIndex ();
		mMessageArray [index] = value;

		if (value) {

			SmartMessage* msg = SmartMessage::GetSmartMessageForScopeAndElement (scope, index);
			bool call = msg->EvaluateCall (mMessageArray);

			if (!call)
				mDoNotCall = true;
		}
	}
}
Exemplo n.º 5
0
int DataSignal :: AddAllSmartMessageReporters () {

	int k = GetObjectScope ();
	int size = SmartMessage::GetSizeOfArrayForScope (k);
	int i;
	int nMsgs = 0;
	SmartMessageReporter* newMsg;
	SmartMessage* nextSmartMsg;
	SmartMessageData target;
	SmartMessageData* smd;
	bool call;

	for (i=0; i<size; i++) {

		if (!mMessageArray [i])
			continue;

		nextSmartMsg = SmartMessage::GetSmartMessageForScopeAndElement (k, i);
		call = nextSmartMsg->EvaluateCall (mMessageArray);

		if (!call)
			mDoNotCall = true;

		if (!nextSmartMsg->EvaluateReport (mMessageArray))
			continue;

		target.SetIndex (i);
		smd = (SmartMessageData*) mMessageDataTable->Find (&target);
		newMsg = new SmartMessageReporter;
		newMsg->SetSmartMessage (nextSmartMsg);
		
		if (smd != NULL)
			newMsg->SetData (smd);

		newMsg->SetPriorityLevel (nextSmartMsg->EvaluateReportLevel (mMessageArray));
		newMsg->SetRestrictionLevel (nextSmartMsg->EvaluateRestrictionLevel (mMessageArray));
		newMsg->SetDoNotCall (!call);
		nMsgs = AddSmartMessageReporter (newMsg);
	}

	MergeAllSmartMessageReporters ();
	return nMsgs;
}
Exemplo n.º 6
0
int CoreBioComponent :: AddAllSmartMessageReporters () {

	int k = GetObjectScope ();
	int size = SmartMessage::GetSizeOfArrayForScope (k);
	int i;
	int nMsgs = 0;
	SmartMessageReporter* newMsg;
	SmartMessage* nextSmartMsg;
	SmartMessageData target;
	SmartMessageData* smd;

	for (i=1; i<=mNumberOfChannels; i++)
		mDataChannels [i]->AddAllSmartMessageReporters ();

	for (i=0; i<size; i++) {

		if (!mMessageArray [i])
			continue;

		nextSmartMsg = SmartMessage::GetSmartMessageForScopeAndElement (k, i);

		if (!nextSmartMsg->EvaluateReport (mMessageArray))
			continue;

		target.SetIndex (i);
		smd = (SmartMessageData*) mMessageDataTable->Find (&target);
		newMsg = new SmartMessageReporter;
		newMsg->SetSmartMessage (nextSmartMsg);
		
		if (smd != NULL)
			newMsg->SetData (smd);

		newMsg->SetPriorityLevel (nextSmartMsg->EvaluateReportLevel (mMessageArray));
		newMsg->SetRestrictionLevel (nextSmartMsg->EvaluateRestrictionLevel (mMessageArray));
		nMsgs = AddSmartMessageReporter (newMsg);
	}

	MergeAllSmartMessageReporters ();
	return nMsgs;
}
Exemplo n.º 7
0
	bool World::sendMessage(SmartMessage & message, Component * sender) {
		bool anyReceiver = false;
		if(message->getEntityTargetType()) {
			// Intentamos conseguir una lista con todas las entidades que comparten un tipo determinado.
			std::string targetType(message->getEntityTargetType());
			EntityStringTableIterator victim = _entitiesByType.find(targetType);
			if(victim != _entitiesByType.end()) {
				EntityListIterator i = victim->second.begin();
				EntityListIterator end = victim->second.end();
				if(message->getEntityTargetName()) {
					// Mandamos el mensaje a todas las entidades con un tipo y nombre determinado.
					std::string targetName(message->getEntityTargetName());
					for(; i != end; ++i) {
						if((*i)->getName() == targetName) {
							anyReceiver = (*i)->sendMessage(message, sender) || anyReceiver;
						}
					}
				} else {
					// Mandamos el mensaje a todas las entidades con un tipo determinado.
					for(; i != end; ++i) {
						anyReceiver = (*i)->sendMessage(message, sender) || anyReceiver;
					}
				}
			}

		} else if(message->getEntityTargetName()) {
			// Intentamos conseguir una lista con todas las entidades que comparten un nombre determinado.
			std::string targetName(message->getEntityTargetName());
			EntityStringTableIterator victim = _entitiesByName.find(targetName);
			if(victim != _entitiesByName.end()) {
				// Mandamos el mensaje a todas las entidades con un nombre determinado.
				EntityListIterator i = victim->second.begin();
				EntityListIterator end = victim->second.end();
				for(; i != end; ++i) {
					anyReceiver = (*i)->sendMessage(message, sender) || anyReceiver;
				}
			}

		} else {
			// Mandamos el mensaje a todas las entidades que han sido registradas.
			EntityIdTableIterator i = _entitiesById.begin();
			EntityIdTableIterator end = _entitiesById.end();
			for(; i != end; ++i) {
				anyReceiver = i->second->sendMessage(message, sender) || anyReceiver;
			}
		}
		return anyReceiver;
	}
Exemplo n.º 8
0
int DataSignal :: AddAllSmartMessageReporters (SmartMessagingComm& comm, int numHigherObjects) {

	if (mReportersAdded)
		return 0;

	mReportersAdded = true;

	int k = GetObjectScope ();
	int size = SmartMessage::GetSizeOfArrayForScope (k);
	int i;
	int nMsgs = 0;
	SmartMessageReporter* newMsg;
	SmartMessage* nextSmartMsg;
	SmartMessageData target;
	SmartMessageData* smd;
	bool call;
	RGString exportProtocol;
	bool editable;
	bool enabled;
	bool hasExportProtocolInfo;
	bool report;
	bool mirror;
	bool displayExport;

	comm.SMOStack [numHigherObjects] = (SmartMessagingObject*) this;
	int topNum = numHigherObjects + 1;

	for (i=0; i<size; i++) {

		nextSmartMsg = SmartMessage::GetSmartMessageForScopeAndElement (k, i);
		editable = nextSmartMsg->IsEditable ();
		hasExportProtocolInfo = nextSmartMsg->HasExportProtocolInfo ();

		if (!mMessageArray [i]) {

			enabled = false;

			if (!editable)
				continue;

			if (!hasExportProtocolInfo)
				continue;
		}

		else
			enabled = true;

		call = nextSmartMsg->EvaluateCall (comm, topNum);

		if (!call)
			mDoNotCall = true;

		if (!nextSmartMsg->GetAllowPeakEdit ())
			mAllowPeakEdit = false;

		report = nextSmartMsg->EvaluateReportContingent (comm, topNum);
		mirror = nextSmartMsg->UseDefaultExportDisplayMode ();

		if (mirror)
			displayExport = report;

		else
			displayExport = nextSmartMsg->DisplayExportInfo ();

		if (!report && !displayExport)
			continue;

		target.SetIndex (i);
		smd = (SmartMessageData*) mMessageDataTable->Find (&target);
		newMsg = new SmartMessageReporter;
		newMsg->SetSmartMessage (nextSmartMsg);
		
		if (smd != NULL)
			newMsg->SetData (smd);

		newMsg->SetPriorityLevel (nextSmartMsg->EvaluateReportLevel (comm, topNum));
		newMsg->SetRestrictionLevel (nextSmartMsg->EvaluateRestrictionLevel (comm, topNum));
		newMsg->SetDoNotCall (!call);
		newMsg->SetEditable (editable);
		newMsg->SetEnabled (enabled);
		newMsg->SetDisplayExportInfo (displayExport);
		newMsg->SetDisplayOsirisInfo (report);

		if (hasExportProtocolInfo) {

			newMsg->SetExportProtocolInformation (nextSmartMsg->GetExportProtocolList ());
			SmartMessagingObject::InsertExportSpecificationsIntoTable (nextSmartMsg);
		}

		newMsg->ComputeViabilityOfExportInfo ();
		nMsgs = AddSmartMessageReporter (newMsg);
	}

	MergeAllSmartMessageReporters ();
	return nMsgs;
}
Exemplo n.º 9
0
int CoreBioComponent :: AddAllSmartMessageReporters (SmartMessagingComm& comm, int numHigherObjects) {

	int k = GetObjectScope ();
	int size = SmartMessage::GetSizeOfArrayForScope (k);
	int i;
	int nMsgs = 0;
	SmartMessageReporter* newMsg;
	SmartMessage* nextSmartMsg;
	SmartMessageData target;
	SmartMessageData* smd;
	bool editable;
	bool enabled;
	bool hasExportProtocolInfo;
	bool report;
	bool mirror;
	bool displayExport;

	for (i=1; i<=mNumberOfChannels; i++)
		mDataChannels [i]->AddAllSmartMessageReporters (comm, numHigherObjects);

	for (i=0; i<size; i++) {

		nextSmartMsg = SmartMessage::GetSmartMessageForScopeAndElement (k, i);
		editable = nextSmartMsg->IsEditable ();
		hasExportProtocolInfo = nextSmartMsg->HasExportProtocolInfo ();

		if (!mMessageArray [i]) {

			enabled = false;

			if (!editable)
				continue;

			if (!hasExportProtocolInfo)
				continue;
		}

		else
			enabled = true;

		report = nextSmartMsg->EvaluateReportContingent (comm, numHigherObjects);
		mirror = nextSmartMsg->UseDefaultExportDisplayMode ();

		if (mirror)
			displayExport = report;

		else
			displayExport = nextSmartMsg->DisplayExportInfo ();

		if (!report && !displayExport)
			continue;

		target.SetIndex (i);
		smd = (SmartMessageData*) mMessageDataTable->Find (&target);
		newMsg = new SmartMessageReporter;
		newMsg->SetSmartMessage (nextSmartMsg);
		
		if (smd != NULL)
			newMsg->SetData (smd);

		newMsg->SetPriorityLevel (nextSmartMsg->EvaluateReportLevel (comm, numHigherObjects));
		newMsg->SetRestrictionLevel (nextSmartMsg->EvaluateRestrictionLevel (comm, numHigherObjects));
		newMsg->SetEditable (editable);
		newMsg->SetEnabled (enabled);
		newMsg->SetDisplayExportInfo (displayExport);
		newMsg->SetDisplayOsirisInfo (report);

		if (hasExportProtocolInfo) {
			
			newMsg->SetExportProtocolInformation (nextSmartMsg->GetExportProtocolList ());
			SmartMessagingObject::InsertExportSpecificationsIntoTable (nextSmartMsg);
		}

		newMsg->ComputeViabilityOfExportInfo ();
		nMsgs = AddSmartMessageReporter (newMsg);
	}

	MergeAllSmartMessageReporters ();
	return nMsgs;
}