RaftLib  0.3a
C++ Stream Processing Template Library
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Port Class Reference
Inheritance diagram for Port:
[legend]
Collaboration diagram for Port:
[legend]

Public Member Functions

 Port (raft::kernel *k)
 
 Port (raft::kernel *k, void *const ptr, const std::size_t nbytes)
 
virtual ~Port ()
 
template<class T >
bool addPort (const std::string port_name)
 
template<class T >
bool addPorts (const std::size_t n_ports=0)
 
const std::type_index & getPortType (const std::string port_name)
 
virtual FIFOoperator[] (const std::string port_name)
 
virtual bool hasPorts ()
 
virtual PortIterator begin ()
 
virtual PortIterator end ()
 
std::size_t count ()
 

Protected Member Functions

template<class T >
void initializeConstMap (PortInfo &pi)
 
PortInfogetPortInfo ()
 
PortInfogetPortInfoFor (const std::string port_name)
 

Protected Attributes

portmap_t portmap
 
raft::kernelkernel = nullptr
 
void *const alloc_ptr = nullptr
 
const std::size_t alloc_ptr_length = 0
 

Friends

class MapBase
 
class GraphTools
 

Constructor & Destructor Documentation

Port::Port ( raft::kernel k)

Port - constructor used to construct a standard port object, needs a reference to the parent kernel for the port_info struct

Parameters
k- raft::kernel*

port.cpp -

Author
: Jonathan Beard
Version
: Thu Aug 28 09:55:47 2014

Copyright 2014 Jonathan Beard

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at:

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Port::Port ( raft::kernel k,
void *const  ptr,
const std::size_t  nbytes 
)

Port - constructor used to construct a port with pre-allocated memory, useful for things like array distribution and reduction

Parameters
k- raft::kernel*
ptr- void*
nbytes- const std::size_t length in bytes
Port::~Port ( )
virtual

~Port - destructor, deletes the FIFO that was given when the object was initalized.

the port map is allocated on the heap so the port_info destructor is called

Member Function Documentation

template<class T >
bool Port::addPort ( const std::string  port_name)
inline

addPort - adds and initializes a port for the name given. Function returns true if added, false if not. Main reason for returning false would be that the port already exists.

Parameters
port_name- const std::string
Returns
bool

we'll have to make a port info object first and pass it by copy to the portmap. Perhaps re-work later with pointers, but for right now this will work and it doesn't necessarily have to be performant since its only executed once.

Here is the caller graph for this function:

template<class T >
bool Port::addPorts ( const std::size_t  n_ports = 0)
inline

addPorts - add ports for an existing buffer, basically allocate buffers in place. These also won't be able to be resized.

Parameters
n_ports- const std::size_t

pointer

PortIterator Port::begin ( )
virtual

begin - get the beginning port.

Returns
PortIterator

Implements PortBase.

std::size_t Port::count ( )

count - get the total number of fifos within this port container

Returns
std::size_t
PortIterator Port::end ( )
virtual

end - get the end port

Returns
PortIterator

Implements PortBase.

PortInfo & Port::getPortInfo ( )
protected

getPortInfo - returns the PortInfo struct for a kernel if we expect it to have a single port. If there's more than one port this function throws an exception.

Returns
std::pair< std::string, PortInfo& >

TODO: extract kernel name to go here too

Here is the caller graph for this function:

PortInfo & Port::getPortInfoFor ( const std::string  port_name)
protected

getPortInfoFor - gets port information for the param port throws an exception if the port doesn't exist.

Parameters
port_name- const std::string
Returns
PortInfo&

Here is the caller graph for this function:

const std::type_index & Port::getPortType ( const std::string  port_name)

getPortType - input the port name, and get the hash for the type of the port. This function is useful for checking the streaming graph to make sure all the ports that are "dynamically" created do in fact have compatible types.

Parameters
port_name- const std::string
Returns
const type_index&
Exceptions
PortNotFoundException
bool Port::hasPorts ( )
virtual

hasPorts - returns true if any ports exists, false otherwise.

Returns
bool

Implements PortBase.

Here is the caller graph for this function:

template<class T >
void Port::initializeConstMap ( PortInfo pi)
inlineprotected

initializeConstMap - hack to get around the inability to otherwise initialize a template function where later we don't have the template parameter. NOTE: this is a biggy, if we have more FIFO types in the future (i.e., sub-classes of FIFO) then we must create an entry here otherwise bad things will happen.

Parameters
pi- PortInfo&

no instrumentation

yes instrumentation

no instrumentation

no instrumentation version defined yet

FIFO & Port::operator[] ( const std::string  port_name)
virtual

operator[] - input the port name and get a port if it exists.

Implements PortBase.

Friends And Related Function Documentation

friend class MapBase
friend

we need some friends

Member Data Documentation

void* const Port::alloc_ptr = nullptr
protected

ptr used for in-place allocations, will not be deleted by the map, also should not be modified by the map either.

const std::size_t Port::alloc_ptr_length = 0
protected

alloc_ptr_length - length of alloc_ptr in bytes.

raft::kernel* Port::kernel = nullptr
protected

parent kernel that owns this port

portmap_t Port::portmap
protected

portmap - container struct with all ports. The mutex should be locked before accessing this structure


The documentation for this class was generated from the following files: