/* this file was generated by the MCOP idl compiler - DO NOT EDIT */

#include "BrahmsArts.h"

// Implementation
BrahmsMidiRecorder_base *BrahmsMidiRecorder_base::_create(const std::string& subClass)
{
	Arts::Object_skel *skel = Arts::ObjectManager::the()->create(subClass);
	assert(skel);
	BrahmsMidiRecorder_base *castedObject = (BrahmsMidiRecorder_base *)skel->_cast(BrahmsMidiRecorder_base::_IID);
	assert(castedObject);
	return castedObject;
}

BrahmsMidiRecorder_base *BrahmsMidiRecorder_base::_fromString(std::string objectref)
{
	Arts::ObjectReference r;

	if(Arts::Dispatcher::the()->stringToObjectReference(r,objectref))
		return BrahmsMidiRecorder_base::_fromReference(r,true);
	return 0;
}

BrahmsMidiRecorder_base *BrahmsMidiRecorder_base::_fromDynamicCast(const Arts::Object& object)
{
	if(object.isNull()) return 0;

	BrahmsMidiRecorder_base *castedObject = (BrahmsMidiRecorder_base *)object._base()->_cast(BrahmsMidiRecorder_base::_IID);
	if(castedObject) return castedObject->_copy();

	return _fromString(object._toString());
}

BrahmsMidiRecorder_base *BrahmsMidiRecorder_base::_fromReference(Arts::ObjectReference r, bool needcopy)
{
	BrahmsMidiRecorder_base *result;
	result = (BrahmsMidiRecorder_base *)Arts::Dispatcher::the()->connectObjectLocal(r,"BrahmsMidiRecorder");
	if(result)
	{
		if(!needcopy)
			result->_cancelCopyRemote();
	}
	else
	{
		Arts::Connection *conn = Arts::Dispatcher::the()->connectObjectRemote(r);
		if(conn)
		{
			result = new BrahmsMidiRecorder_stub(conn,r.objectID);
			if(needcopy) result->_copyRemote();
			result->_useRemote();
			if (!result->_isCompatibleWith("BrahmsMidiRecorder")) {
				result->_release();
				return 0;
			}
		}
	}
	return result;
}

std::vector<std::string> BrahmsMidiRecorder_base::_defaultPortsIn() const {
	std::vector<std::string> ret;
	return ret;
}
std::vector<std::string> BrahmsMidiRecorder_base::_defaultPortsOut() const {
	std::vector<std::string> ret;
	return ret;
}

void *BrahmsMidiRecorder_base::_cast(unsigned long iid)
{
	if(iid == BrahmsMidiRecorder_base::_IID) return (BrahmsMidiRecorder_base *)this;
	if(iid == Arts::MidiPort_base::_IID) return (Arts::MidiPort_base *)this;
	if(iid == Arts::Object_base::_IID) return (Arts::Object_base *)this;
	return 0;
}

BrahmsMidiRecorder_stub::BrahmsMidiRecorder_stub()
{
	// constructor for subclasses (don't use directly)
}

BrahmsMidiRecorder_stub::BrahmsMidiRecorder_stub(Arts::Connection *connection, long objectID)
	: Arts::Object_stub(connection, objectID)
{
	// constructor to create a stub for an object
}

std::vector<Arts::MidiEvent> * BrahmsMidiRecorder_stub::getQueue()
{
	long methodID = _lookupMethodFast("method:00000009676574517565756500000000112a417274733a3a4d6964694576656e7400000000020000000000000000");
	long requestID;
	Arts::Buffer *request, *result;
	request = Arts::Dispatcher::the()->createRequest(requestID,_objectID,methodID);
	request->patchLength();
	_connection->qSendBuffer(request);

	result = Arts::Dispatcher::the()->waitForResult(requestID,_connection);
	std::vector<Arts::MidiEvent> *_returnCode = new std::vector<Arts::MidiEvent>;
	if(!result) return _returnCode; // error occured
	Arts::readTypeSeq(*result,*_returnCode);
	delete result;
	return _returnCode;
}

void BrahmsMidiRecorder_stub::setMidiThru(Arts::MidiPort port)
{
	long methodID = _lookupMethodFast("method:0000000c7365744d696469546872750000000005766f69640000000002000000010000000f417274733a3a4d696469506f72740000000005706f7274000000000000000000");
	long requestID;
	Arts::Buffer *request, *result;
	request = Arts::Dispatcher::the()->createRequest(requestID,_objectID,methodID);
	Arts::writeObject(*request,port._base());
	request->patchLength();
	_connection->qSendBuffer(request);

	result = Arts::Dispatcher::the()->waitForResult(requestID,_connection);
	if(result) delete result;
}

bool BrahmsMidiRecorder_stub::record()
{
	long methodID = _lookupMethodFast("method:0000000c5f6765745f7265636f72640000000008626f6f6c65616e00000000020000000000000000");
	long requestID;
	Arts::Buffer *request, *result;
	request = Arts::Dispatcher::the()->createRequest(requestID,_objectID,methodID);
	request->patchLength();
	_connection->qSendBuffer(request);

	result = Arts::Dispatcher::the()->waitForResult(requestID,_connection);
	if(!result) return false; // error occured
	bool returnCode = result->readBool();
	delete result;
	return returnCode;
}

void BrahmsMidiRecorder_stub::record(bool newValue)
{
	long methodID = _lookupMethodFast("method:0000000c5f7365745f7265636f72640000000005766f696400000000020000000100000008626f6f6c65616e00000000096e657756616c7565000000000000000000");
	long requestID;
	Arts::Buffer *request, *result;
	request = Arts::Dispatcher::the()->createRequest(requestID,_objectID,methodID);
	request->writeBool(newValue);
	request->patchLength();
	_connection->qSendBuffer(request);

	result = Arts::Dispatcher::the()->waitForResult(requestID,_connection);
	if(result) delete result;
}

std::string BrahmsMidiRecorder_skel::_interfaceName()
{
	return "BrahmsMidiRecorder";
}

bool BrahmsMidiRecorder_skel::_isCompatibleWith(const std::string& interfacename)
{
	if (interfacename == "BrahmsMidiRecorder") return true;
	if (interfacename == "Arts::MidiPort") return true;
	if (interfacename == "Arts::Object") return true;
	return false;
}

std::string BrahmsMidiRecorder_skel::_interfaceNameSkel()
{
	return "BrahmsMidiRecorder";
}

// getQueue
static void _dispatch__BrahmsMidiRecorder_00(void *object, Arts::Buffer *, Arts::Buffer *result)
{
	std::vector<Arts::MidiEvent> *_returnCode = ((BrahmsMidiRecorder_skel *)object)->getQueue();
	Arts::writeTypeSeq(*result,*_returnCode);
	delete _returnCode;
}

// setMidiThru
static void _dispatch__BrahmsMidiRecorder_01(void *object, Arts::Buffer *request, Arts::Buffer *)
{
	Arts::MidiPort_base* _temp_port;
	Arts::readObject(*request,_temp_port);
	Arts::MidiPort port = Arts::MidiPort::_from_base(_temp_port);
	((BrahmsMidiRecorder_skel *)object)->setMidiThru(port);
}

// _get_record
static void _dispatch__BrahmsMidiRecorder_02(void *object, Arts::Buffer *, Arts::Buffer *result)
{
	result->writeBool(((BrahmsMidiRecorder_skel *)object)->record());
}

// _set_record
static void _dispatch__BrahmsMidiRecorder_03(void *object, Arts::Buffer *request, Arts::Buffer *)
{
	bool newValue = request->readBool();
	((BrahmsMidiRecorder_skel *)object)->record(newValue);
}

void BrahmsMidiRecorder_skel::_buildMethodTable()
{
	Arts::Buffer m;
	m.fromString(
        "MethodTable:00000009676574517565756500000000112a417274733a3a4d6964"
        "694576656e74000000000200000000000000000000000c7365744d696469546872"
        "750000000005766f69640000000002000000010000000f417274733a3a4d696469"
        "506f72740000000005706f72740000000000000000000000000c5f6765745f7265"
        "636f72640000000008626f6f6c65616e000000000200000000000000000000000c"
        "5f7365745f7265636f72640000000005766f696400000000020000000100000008"
        "626f6f6c65616e00000000096e657756616c7565000000000000000000",
		"MethodTable"
	);
	_addMethod(_dispatch__BrahmsMidiRecorder_00,this,Arts::MethodDef(m));
	_addMethod(_dispatch__BrahmsMidiRecorder_01,this,Arts::MethodDef(m));
	_addMethod(_dispatch__BrahmsMidiRecorder_02,this,Arts::MethodDef(m));
	_addMethod(_dispatch__BrahmsMidiRecorder_03,this,Arts::MethodDef(m));
	Arts::MidiPort_skel::_buildMethodTable();
}

BrahmsMidiRecorder_skel::BrahmsMidiRecorder_skel()
{
}

Arts::Object_base* BrahmsMidiRecorder::_Creator() {
	return BrahmsMidiRecorder_base::_create();
}

unsigned long BrahmsMidiRecorder_base::_IID = Arts::MCOPUtils::makeIID("BrahmsMidiRecorder");

static Arts::IDLFileReg IDLFileReg_BrahmsArts("BrahmsArts",
    "IDLFile:000000010000000000000000000000000100000013427261686d734d696469"
    "5265636f7264657200000000010000000f417274733a3a4d696469506f727400000000"
    "0200000009676574517565756500000000112a417274733a3a4d6964694576656e7400"
    "0000000200000000000000000000000c7365744d696469546872750000000005766f69"
    "640000000002000000010000000f417274733a3a4d696469506f72740000000005706f"
    "727400000000000000000000000001000000077265636f72640000000008626f6f6c65"
    "616e000000001300000000000000000000000000000000"
);
