public abstract class DataSource extends Object
Constructor and Description |
---|
DataSource(boolean writeable)
Creates a new data source.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the DataSource and the resources associated with it.
|
void |
concludeWrite(WriteBuffer writeBuffer,
ExceptionHandler exceptionHandler)
Releases the resources associated with the given write buffer.
|
void |
connect(DataRecipe recipe)
Connects to a set of channels based on the given recipe.
|
protected abstract ChannelHandler |
createChannel(String channelName)
Creates a channel handler for the given name.
|
void |
disconnect(DataRecipe recipe)
Disconnects the set of channels given by the recipe.
|
Map<String,ChannelHandler> |
getChannels()
Returns the channel handlers for this data source.
|
boolean |
isWriteable()
Returns true whether the channels of this data source can be
written to.
|
void |
prepareWrite(WriteBuffer writeBuffer,
ExceptionHandler exceptionHandler)
Prepares the channels defined in the write buffer for writes.
|
void |
write(WriteBuffer writeBuffer,
Runnable callback,
ExceptionHandler exceptionHandler)
Writes the contents in the given write buffers to the channels
of this data sources.
|
public DataSource(boolean writeable)
writeable
- whether the data source implements write operationspublic boolean isWriteable()
protected abstract ChannelHandler createChannel(String channelName)
channelName
- the name for a new channelpublic void connect(DataRecipe recipe)
The data source must update the value caches relative to each channel. Before updating any cache, it must lock the collector relative to that cache and after any update it must notify the collector.
recipe
- the instructions for the data connectionpublic void disconnect(DataRecipe recipe)
The disconnect call is guaranteed to be given the same object, so that the recipe itself can be used as a key in a map to retrieve the list of resources needed to be closed.
recipe
- the instructions for the data connectionpublic void prepareWrite(WriteBuffer writeBuffer, ExceptionHandler exceptionHandler)
If these are channels over the network, it will create the network connections with the underlying libraries.
writeBuffer
- the buffer that will contain the write dataexceptionHandler
- where to report the exceptionspublic void concludeWrite(WriteBuffer writeBuffer, ExceptionHandler exceptionHandler)
Will close network channels and deallocate memory needed.
writeBuffer
- the buffer that will no longer be usedexceptionHandler
- where to report the exceptionspublic void write(WriteBuffer writeBuffer, Runnable callback, ExceptionHandler exceptionHandler)
The write buffer need to be first prepared with prepareWrite(org.epics.pvmanager.WriteBuffer, org.epics.pvmanager.ExceptionHandler)
and then cleaned up with concludeWrite(org.epics.pvmanager.WriteBuffer, org.epics.pvmanager.ExceptionHandler)
.
writeBuffer
- the buffer containing the data to writecallback
- function to call when the write is concludedexceptionHandler
- where to report the exceptionspublic Map<String,ChannelHandler> getChannels()
public void close()
Copyright © 2012. All Rights Reserved.