SerialPortImpl.cpp revision f503eb77dfd7a1fd153f0ad602d78d783f7fe321
/** @file
*
* VirtualBox COM class implementation
*/
/*
* Copyright (C) 2006-2007 innotek GmbH
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License as published by the Free Software Foundation,
* in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
* distribution. VirtualBox OSE is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#include "SerialPortImpl.h"
#include "MachineImpl.h"
#include "VirtualBoxImpl.h"
#include "Logging.h"
#include <iprt/cpputils.h>
// constructor / destructor
/////////////////////////////////////////////////////////////////////////////
{
return S_OK;
}
void SerialPort::FinalRelease()
{
uninit();
}
// public initializer/uninitializer for internal purposes only
/////////////////////////////////////////////////////////////////////////////
/**
* Initializes the Serial Port object.
*
* @param aParent Handle of the parent object.
*/
{
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan (this);
/* mPeer is left null */
/* initialize data */
/* Confirm a successful initialization */
return S_OK;
}
/**
* Initializes the Serial Port object given another serial port object
* (a kind of copy constructor). This object shares data with
* the object passed as an argument.
*
* @note This object must be destroyed before the original object
* it shares data with is destroyed.
*
* @note Locks @a aThat object for reading.
*/
{
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan (this);
/* Confirm a successful initialization */
return S_OK;
}
/**
* Initializes the guest object given another guest object
* (a kind of copy constructor). This object makes a private copy of data
* of the original object passed as an argument.
*
* @note Locks @a aThat object for reading.
*/
{
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan (this);
/* mPeer is left null */
/* Confirm a successful initialization */
return S_OK;
}
/**
* Uninitializes the instance and sets the ready flag to FALSE.
* Called either from FinalRelease() or by the parent when it gets destroyed.
*/
void SerialPort::uninit()
{
LogFlowThisFunc (("\n"));
/* Enclose the state transition Ready->InUninit->NotReady */
AutoUninitSpan autoUninitSpan (this);
if (autoUninitSpan.uninitDone())
return;
}
// public methods only for internal purposes
////////////////////////////////////////////////////////////////////////////////
/**
* @note Locks this object for writing.
*/
bool SerialPort::rollback()
{
/* sanity */
AutoCaller autoCaller (this);
bool changed = false;
if (mData.isBackedUp())
{
/* we need to check all data to see whether anything will be changed
* after rollback */
}
return changed;
}
/**
* @note Locks this object for writing, together with the peer object (also
* for writing) if there is one.
*/
void SerialPort::commit()
{
/* sanity */
AutoCaller autoCaller (this);
/* sanity too */
/* lock both for writing since we modify both */
if (mData.isBackedUp())
{
if (mPeer)
{
/* attach new data to the peer and reshare it */
}
}
}
/**
* @note Locks this object for writing, together with the peer object
* represented by @a aThat (locked for reading).
*/
{
/* sanity */
AutoCaller autoCaller (this);
/* sanity too */
/* peer is not modified, lock it for reading */
/* this will back up current data */
}
{
AutoCaller autoCaller (this);
/* slot number (required) */
/* slot unicity is guaranteed by XML Schema */
/* enabled (required) */
bool fEnabled = false;
/* I/O base (required) */
/* IRQ (required) */
/* host mode (required) */
if (mode == L"HostPipe")
else if (mode == L"HostDevice")
else
/* server mode */
bool fServer = true;
return S_OK;
}
{
AutoCaller autoCaller (this);
AutoReaderLock alock (this);
const char *mode;
{
default:
mode = "Disconnected";
break;
case PortMode_HostPipePort:
mode = "HostPipe";
break;
case PortMode_HostDevicePort:
mode = "HostDevice";
break;
}
{
}
return S_OK;
}
// ISerialPort properties
/////////////////////////////////////////////////////////////////////////////
{
if (!aEnabled)
return E_POINTER;
AutoCaller autoCaller (this);
AutoReaderLock alock (this);
return S_OK;
}
{
AutoCaller autoCaller (this);
/* the machine needs to be mutable */
{
/* leave the lock before informing callbacks */
mParent->onSerialPortChange (this);
}
return S_OK;
}
{
if (!aHostMode)
return E_POINTER;
AutoCaller autoCaller (this);
AutoReaderLock alock (this);
return S_OK;
}
{
AutoCaller autoCaller (this);
/* the machine needs to be mutable */
bool emitChangeEvent = false;
{
if (aHostMode == PortMode_DisconnectedPort)
{
}
emitChangeEvent = true;
}
if (emitChangeEvent)
{
/* leave the lock before informing callbacks */
mParent->onSerialPortChange (this);
}
return rc;
}
{
if (!aSlot)
return E_POINTER;
AutoCaller autoCaller (this);
AutoReaderLock alock (this);
return S_OK;
}
{
if (!aIRQ)
return E_POINTER;
AutoCaller autoCaller (this);
AutoReaderLock alock (this);
return S_OK;
}
{
AutoCaller autoCaller (this);
/* the machine needs to be mutable */
bool emitChangeEvent = false;
{
emitChangeEvent = true;
}
if (emitChangeEvent)
{
/* leave the lock before informing callbacks */
mParent->onSerialPortChange (this);
}
return rc;
}
{
if (!aIOBase)
return E_POINTER;
AutoCaller autoCaller (this);
AutoReaderLock alock (this);
return S_OK;
}
{
AutoCaller autoCaller (this);
/* the machine needs to be mutable */
bool emitChangeEvent = false;
{
emitChangeEvent = true;
}
if (emitChangeEvent)
{
/* leave the lock before informing callbacks */
mParent->onSerialPortChange (this);
}
return rc;
}
{
if (!aPath)
return E_POINTER;
AutoCaller autoCaller (this);
AutoReaderLock alock (this);
return S_OK;
}
{
if (!aPath)
return E_INVALIDARG;
AutoCaller autoCaller (this);
/* the machine needs to be mutable */
{
/* leave the lock before informing callbacks */
return mParent->onSerialPortChange (this);
}
return S_OK;
}
{
if (!aServer)
return E_POINTER;
AutoCaller autoCaller (this);
AutoReaderLock alock (this);
return S_OK;
}
{
AutoCaller autoCaller (this);
/* the machine needs to be mutable */
{
/* leave the lock before informing callbacks */
mParent->onSerialPortChange (this);
}
return S_OK;
}