Exemplo n.º 1
0
bool EventConsumer::AddConsumer (ITransformable *source, IConsumer *consumer, ITransformer *transformer) {

	if (transformer) {
		return AddConsumer (1, &source, consumer, &transformer);
	} else {
		return AddConsumer (1, &source, consumer);
	}

}
Exemplo n.º 2
0
bool ConsumerParserClass::ParseConsumerInstance(const wchar_t* path, const wchar_t* szNamespace, const wchar_t* szType, const wchar_t* szInstanceName) {
  if (Init(path) && szNamespace && szType) {
    IndexBTR index(m_bXP);
    std::string szSearch;
    BuildInstanceSearchString(szNamespace, szType, szInstanceName, szSearch, m_bXP);
    if (index.SearchBTRFile(path, Map, szSearch)) {
      std::vector<std::string> *records = index.GetResults();
      if (records && records->size()) {
        InstanceStruct cs;
        ::memset(&cs, 0, sizeof(InstanceStruct));
        if (ConstructInstanceRecord(records->at(0), cs)) {
          AddConsumer(cs);
          return true;
        }
      }
    }
  }
  return false;
}
Exemplo n.º 3
0
bool ConsumerParserClass::ParseAllConsumers(const wchar_t* path, const wchar_t* szNamespace) {
  if (Init(path) && szNamespace) {
    IndexBTR index(m_bXP);
    std::string szSearch;
    BuildConsumerClassSearchString(szNamespace, szSearch, m_bXP);
    if (index.SearchBTRFile(path, Map, szSearch)) {
      std::vector<std::string> *records = index.GetResults();
      if (records) {
        std::vector<std::string>::iterator it = records->begin();
        std::vector<std::string> aConsumerClasses;
        for (; it != records->end(); ++it) {
          std::string szClass;
          if (GetNewConsumerClass(*it, szNamespace, szClass, m_bXP)) {
            std::string szInstSearch;
            BuildAllInstancesSearchString(szNamespace, szClass, szInstSearch, m_bXP);
            aConsumerClasses.push_back(szInstSearch);
          }
        }
        if (aConsumerClasses.size()) {
          std::vector<std::string>::iterator it = aConsumerClasses.begin();
          for (; it != aConsumerClasses.end(); ++it) {
            if (index.SearchBTRFile(path, Map, *it)) {
              std::vector<std::string> *records = index.GetResults();
              if (records) {
                std::vector<std::string>::iterator it = records->begin();
                for (; it != records->end(); ++it) {
                  InstanceStruct cs;
                  ::memset(&cs, 0, sizeof(InstanceStruct));
                  if (ConstructInstanceRecord(*it, cs))
                    AddConsumer(cs);
                }
              }
            }
          }
        }
        return true;
      }
    }
  }
  return false;
}
Exemplo n.º 4
0
bool ConsumerParserClass::ParseAllConsumersByType(const wchar_t* path, const wchar_t* szNamespace, const wchar_t* szType) {
  if (Init(path) && szNamespace && szType) {
    IndexBTR index(m_bXP);
    std::string szSearch;
    BuildAllInstancesSearchString(szNamespace, szType, szSearch, m_bXP);
    if (index.SearchBTRFile(path, Map, szSearch)) {
      std::vector<std::string> *records = index.GetResults();
      if (records) {
        std::vector<std::string>::iterator it = records->begin();
        for (; it != records->end(); ++it) {
          InstanceStruct cs;
          ::memset(&cs, 0, sizeof(InstanceStruct));
          if (ConstructConsumerRecord(*it, szNamespace, szType, cs))
            AddConsumer(cs);
        }
        return true;
      }
    }
  }
  return false;
}
Exemplo n.º 5
0
void
PatchView::HandleMidiEvent(BMessage* msg)
{
	SET_DEBUG_ENABLED(true);
	
	int32 op;
	if (msg->FindInt32("be:op", &op) != B_OK) {
		PRINT(("PatchView::HandleMidiEvent: \"op\" field not found\n"));
		return;
	}

	switch (op) {
	case B_MIDI_REGISTERED:
		{
			int32 id;
			if (msg->FindInt32("be:id", &id) != B_OK) {
				PRINT(("PatchView::HandleMidiEvent: \"be:id\""
					" field not found in B_MIDI_REGISTERED event\n"));
				break;
			}
			
			const char* type;
			if (msg->FindString("be:type", &type) != B_OK) {
				PRINT(("PatchView::HandleMidiEvent: \"be:type\""
					" field not found in B_MIDI_REGISTERED event\n"));
				break;
			}
			
			PRINT(("MIDI Roster Event B_MIDI_REGISTERED: id=%" B_PRId32
					", type=%s\n", id, type));
			if (strcmp(type, "producer") == 0)
				AddProducer(id);
			else if (strcmp(type, "consumer") == 0)
				AddConsumer(id);
		}
		break;
	case B_MIDI_UNREGISTERED:
		{
			int32 id;
			if (msg->FindInt32("be:id", &id) != B_OK) {
				PRINT(("PatchView::HandleMidiEvent: \"be:id\""
					" field not found in B_MIDI_UNREGISTERED\n"));
				break;
			}
			
			const char* type;
			if (msg->FindString("be:type", &type) != B_OK) {
				PRINT(("PatchView::HandleMidiEvent: \"be:type\""
					" field not found in B_MIDI_UNREGISTERED\n"));
				break;
			}
			
			PRINT(("MIDI Roster Event B_MIDI_UNREGISTERED: id=%" B_PRId32
					", type=%s\n", id, type));
			if (strcmp(type, "producer") == 0)
				RemoveProducer(id);
			else if (strcmp(type, "consumer") == 0)
				RemoveConsumer(id);
		}
		break;
	case B_MIDI_CHANGED_PROPERTIES:
		{
			int32 id;
			if (msg->FindInt32("be:id", &id) != B_OK) {
				PRINT(("PatchView::HandleMidiEvent: \"be:id\""
					" field not found in B_MIDI_CHANGED_PROPERTIES\n"));
				break;
			}
			
			const char* type;
			if (msg->FindString("be:type", &type) != B_OK) {
				PRINT(("PatchView::HandleMidiEvent: \"be:type\""
					" field not found in B_MIDI_CHANGED_PROPERTIES\n"));
				break;
			}
			
			BMessage props;
			if (msg->FindMessage("be:properties", &props) != B_OK) {
				PRINT(("PatchView::HandleMidiEvent: \"be:properties\""
					" field not found in B_MIDI_CHANGED_PROPERTIES\n"));
				break;
			}
			
			PRINT(("MIDI Roster Event B_MIDI_CHANGED_PROPERTIES: id=%" B_PRId32
					", type=%s\n", id, type));
			if (strcmp(type, "producer") == 0)
				UpdateProducerProps(id, &props);
			else if (strcmp(type, "consumer") == 0)
				UpdateConsumerProps(id, &props);
			
		}
		break;
	case B_MIDI_CHANGED_NAME:
	case B_MIDI_CHANGED_LATENCY:
		// we don't care about these
		break;
	case B_MIDI_CONNECTED:
		{
			int32 prod;
			if (msg->FindInt32("be:producer", &prod) != B_OK) {
				PRINT(("PatchView::HandleMidiEvent: \"be:producer\""
					" field not found in B_MIDI_CONNECTED\n"));
				break;
			}
			
			int32 cons;
			if (msg->FindInt32("be:consumer", &cons) != B_OK) {
				PRINT(("PatchView::HandleMidiEvent: \"be:consumer\""
					" field not found in B_MIDI_CONNECTED\n"));
				break;
			}
			PRINT(("MIDI Roster Event B_MIDI_CONNECTED: producer=%" B_PRId32
					", consumer=%" B_PRId32 "\n", prod, cons));
			Connect(prod, cons);
		}
		break;
	case B_MIDI_DISCONNECTED:
		{
			int32 prod;
			if (msg->FindInt32("be:producer", &prod) != B_OK) {
				PRINT(("PatchView::HandleMidiEvent: \"be:producer\""
					" field not found in B_MIDI_DISCONNECTED\n"));
				break;
			}
			
			int32 cons;
			if (msg->FindInt32("be:consumer", &cons) != B_OK) {
				PRINT(("PatchView::HandleMidiEvent: \"be:consumer\""
					" field not found in B_MIDI_DISCONNECTED\n"));
				break;
			}
			PRINT(("MIDI Roster Event B_MIDI_DISCONNECTED: producer=%" B_PRId32
					", consumer=%" B_PRId32 "\n", prod, cons));
			Disconnect(prod, cons);
		}
		break;
	default:
		PRINT(("PatchView::HandleMidiEvent: unknown opcode %" B_PRId32 "\n",
			op));
		break;
	}
}