Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

L1394::Session Class Reference

The Session class is the most most important class for the programmer. More...

#include <l1394_session.h>

List of all members.

Session constructor

These functions creates the Session objects.

 Session ()
 Init a Session.
virtual ~Session ()
static SessiongetSession ()
 This method returns a pointer to the Session object.

Public Member Functions

Access the FireWire bus
These functions search and return the different nodes on the FireWire bus. All functions search on all installed FireWire cards.

int getCardCount () const
 This method returns the number of cards in your computer.
const std::vector< std::string > & getIsoDevices () const
void addEventHandle (EventHandle *)
 An EventHandle object added with this method reports about busresets on all cards.
void removeEventHandle (EventHandle *)
 This method removes an EventHandle.
bool nodeExist (u_int64_t guid) const
 This method tests, if a node with a specific guid exist.
const CardgetCard (unsigned int card_id) const
 This method returns a pointer to the i'th card (beginning by 0).
list< const Card * > getCardList () const
 This method returns the card_array.
DevicefindDevice (const string &name="Device") const
 This method finds the first Camera and returns it.
DevicefindDevice (u_int64_t guid)
 This method finds the Device with GUID guid.
CamerafindCamera (u_int64_t guid)
 This method finds the Camera with GUID guid.
VcrfindVcr (u_int64_t guid)
 This method finds the Device with GUID guid.
CamerafindCamera (const string &name="Camera") const
 This method finds the first Camera and returns it.
VcrfindVcr (const string &name="Vcr") const
 This method finds a Vcr and returns a pointer to it.
AvcVcrfindAvcVcr (const string &name="AvcVcr") const
 This method finds an AvcVcr and returns a pointer to it.
DccCamerafindDccCamera (const string &name="DccCamera") const
 This method finds the first DccCamera on FireWire bus and return it.
AvcCamerafindAvcCamera (const string &name="AvcCamera") const
 This method find the first AvcCamera on the FireWire bus.
list< Device * > getAllDevices () const
 This method returns a list of all Cameras on the FireWire bus.
list< Camera * > getAllCameras () const
 This method returns a list of all Cameras on the FireWire bus.
list< Vcr * > getAllVcrs () const
 This method returns a list with all Vcrs on the FireWire bus.
list< AvcVcr * > getAllAvcVcrs () const
 This method returns a list with all AvcVcrs on the FireWire bus.
list< DccCamera * > getAllDccCameras () const
 This method finds all DccCameras and return a list of them.
list< AvcCamera * > getAllAvcCameras () const
 This method finds all AvcCameras and return a list of them.

Static Public Member Functions

Configure the library
These functions set some internal parameters. This library uses three ostreams to print messages. The debug_stream prints debug_messages, the message_stream prints some more or less informative messages and the error_stream prints error messages. By default all streams are set to cout. To disable the messages, set the stream to NULL.

static void setDebugStream (std::ostream *o)
 This method sets the debug output.
static void setMessageStream (std::ostream *o)
 This method sets the standard output.
static void setErrorStream (std::ostream *o)
 This method sets the error output.
static void setWarningStream (std::ostream *o)
 This method sets the error output.
static void safeMode (bool mode=false, int delay=30)
 This method enables the safe-mode for the read and write functions.

Static Public Attributes

static bool session_is_running = true
static ThreadMutex global_mutex

Protected Member Functions

NodegetNode (u_int64_t guid) const
 This method returns a pointer to a node specified by its guid return NULL, if node doesn't exist.
NodefindNode (int node_type) const
 finds a node, specified by it's node_type.
list< Node * > getAllNodes (int node_type) const
 returns a list with Nodes from type node_type

Friends

class L1394::CreateUsingNew< Session >


Detailed Description

The Session class is the most most important class for the programmer.

Every program using this library needs exactly one Session object. (There is further now way to create more than one object.)

The Session object has two major jobs. The first part is, to instantiate the Card objects and handle incoming events from the driver, like bus-resets. The Card object instantiate the L1394 Nodes for the connected nodes on FireWire bus.
The second one is, to represent a simple interface to find or get the L1394 Nodes for a FireWire node. These functions search on all FireWire cards.
There are also some static functions to set some internal parameters, like the output streams, or a so called 'safe-mode'. For more information about these mothods see the section 'Configure the Library'.

Normally your application needs to include the l1394_session.h file, for classes in namespace L1394.
To create a Session object you can call the static member function Session::getSession(), or the macro GetSession();

The session object is also responsible to delete all L1394 objects. You must not delete any object from this class, except the Session object itself!! If you delete some objects, no correct work is possible!!!!

If the getSession() function fails, the library quit the application with an error message. (The library quits an application only if the getSession() function fails)

A little example:

  #include <l1394_session.h>

  using namespace L1394;

  int main(int argc, char* argv[])
  {
    //Start a new Session.
    Session *session = GetSession();

    for (int i = 0; i< session->getCardCount(); i++)
      session->getCard(i)->printNodeList();  //prints the device list to cout

    //Get all cameras
    list<Camera*> camera_list = session->getAllCameras();
    list<Camera*>::iterator camera_iterator = camera_list.begin();

    // Now you can work with the cameras. For example calibrate all cameras.
    for (int i = 0; i< camera_list.size(); i++)
    {
      if ((*camera_iterator)->whiteBalance()->hasFeature())
        (*camera_iterator)->whiteBalance()->onePush();
      if ((*camera_iterator)->zoom()->hasFeature())
        (*camera_iterator)->zoom()->setValue((*camera_iterator)->zoom()->getMinValue));
      //and so on ....
    }

    //Get all vcrs
    list<Vcr*> vcr_list = session->getAllVcrs();
    list<Vcr*>::iterator vcr_iterator = vcr_iterator.begin();

    //Now you can work with the devices.
    for (int i = 0; i< vcr_list.size(); i++)
    {
      //start all vcrs
      (*vcr_iterator)->play()->send();
      vcr_iterator++;
    }

  }

For more information see the tutorial.

Author:
Michael Repplinger

Definition at line 255 of file l1394_session.h.


Constructor & Destructor Documentation

L1394::Session::Session  )  [protected]
 

Init a Session.

Definition at line 31 of file l1394_session.cpp.

References L1394::Singleton< T, CreationPolicy, LifetimePolicy, ThreadingModel >::getInstance(), global_mutex, and session_is_running.

L1394::Session::~Session  )  [protected, virtual]
 

Definition at line 49 of file l1394_session.cpp.


Member Function Documentation

L1394::Session::addEventHandle EventHandle  ) 
 

An EventHandle object added with this method reports about busresets on all cards.

Definition at line 336 of file l1394_session.cpp.

References L1394::internal::Message::errorStream().

Referenced by SimpleEventHandle::SimpleEventHandle().

L1394::Session::findAvcCamera const string &  name = "AvcCamera"  )  const
 

This method find the first AvcCamera on the FireWire bus.

Returns:
AvcCamera* : pointer to the first AvcCamera, NULL if no AvcCamera exist.

L1394::Session::findAvcVcr const string &  name = "AvcVcr"  )  const
 

This method finds an AvcVcr and returns a pointer to it.

Returns:
Vcr* : pointer to the first AvcVcr found, NULL if no AvcVcr exist.

L1394::Session::findCamera const string &  name = "Camera"  )  const
 

This method finds the first Camera and returns it.

This method searches on all Card objects.

Returns:
Camera* : pointer to the first Camera found on a card, NULL if no Camera exist.

Definition at line 206 of file l1394_session.cpp.

References getAllCameras().

L1394::Session::findCamera u_int64_t  guid  ) 
 

This method finds the Camera with GUID guid.

This method searches on all Card objects.

Returns:
Camera* : pointer to the Camera with GUID guid, NULL if no such Camera exist.

Definition at line 425 of file l1394_session.cpp.

References findDevice().

Referenced by main().

L1394::Session::findDccCamera const string &  name = "DccCamera"  )  const
 

This method finds the first DccCamera on FireWire bus and return it.

Returns:
DccCamera* : pointer to the first DccCamera, NULL if no DccCamera exist.

Definition at line 295 of file l1394_session.cpp.

References getAllDccCameras().

L1394::Session::findDevice u_int64_t  guid  ) 
 

This method finds the Device with GUID guid.

This method searches on all Card objects.

Returns:
Device* : pointer to the device with GUID guid, NULL if no such Device exist.

Definition at line 413 of file l1394_session.cpp.

References getAllDevices().

L1394::Session::findDevice const string &  name = "Device"  )  const
 

This method finds the first Camera and returns it.

This method searches on all Card objects.

Returns:
Device* : pointer to the first Camera found on a card, NULL if no Camera exist.

Definition at line 395 of file l1394_session.cpp.

References getAllDevices().

Referenced by findCamera(), and findVcr().

L1394::Session::findNode int  node_type  )  const [protected]
 

finds a node, specified by it's node_type.

A pointer to the first found node was returned, NULL if no node with this type was found.

Parameters:
node_type : value that specify a node-type, defined in class Node.

Definition at line 137 of file l1394_session.cpp.

References getCard(), and L1394::internal::Message::messageStream().

L1394::Session::findVcr const string &  name = "Vcr"  )  const
 

This method finds a Vcr and returns a pointer to it.

Returns:
Vcr* : pointer to the first vcr found, NULL if no Vcr exist.

Definition at line 238 of file l1394_session.cpp.

References getAllVcrs().

L1394::Session::findVcr u_int64_t  guid  ) 
 

This method finds the Device with GUID guid.

This method searches on all Card objects.

Returns:
Vcr* : pointer to the Vcr with GUID guid, NULL if no such Device exist.

Definition at line 429 of file l1394_session.cpp.

References findDevice().

L1394::Session::getAllAvcCameras  )  const
 

This method finds all AvcCameras and return a list of them.

Returns:
list<AvcCamera*> :a stl-list with pointer to all AvcCameras.

Definition at line 308 of file l1394_session.cpp.

References L1394::_Camera, L1394::_FcpNode, and getAllNodes().

Referenced by getAllCameras().

L1394::Session::getAllAvcVcrs  )  const
 

This method returns a list with all AvcVcrs on the FireWire bus.

Returns:
list<AvcVcr*> : return a stl-list with pointer to all AvcVcrs .

Definition at line 272 of file l1394_session.cpp.

References getAllVcrs().

L1394::Session::getAllCameras  )  const
 

This method returns a list of all Cameras on the FireWire bus.

This method searches on all Cards

Returns:
list<Camera*> : returns a stl-list with pointer to all Cameras.

Definition at line 222 of file l1394_session.cpp.

References getAllAvcCameras(), and getAllDccCameras().

Referenced by findCamera(), main(), SimpleEventHandle::SimpleEventHandle(), and SimpleEventHandle::~SimpleEventHandle().

L1394::Session::getAllDccCameras  )  const
 

This method finds all DccCameras and return a list of them.

Returns:
list<DccCamera*> :a stl-list with pointer to all DccCameras.

Definition at line 283 of file l1394_session.cpp.

References L1394::_DccNode, and getAllNodes().

Referenced by findDccCamera(), getAllCameras(), and main().

L1394::Session::getAllDevices  )  const
 

This method returns a list of all Cameras on the FireWire bus.

This method searches on all Cards

Returns:
list<Camera*> : returns a stl-list with pointer to all Cameras.

Definition at line 495 of file l1394_session.cpp.

References L1394::Card::getExplicitNode().

Referenced by findDevice().

L1394::Session::getAllNodes int  node_type  )  const [protected]
 

returns a list with Nodes from type node_type

Parameters:
node_type : the node type

Definition at line 186 of file l1394_session.cpp.

References getCard().

Referenced by getAllAvcCameras(), getAllDccCameras(), and getAllVcrs().

L1394::Session::getAllVcrs  )  const
 

This method returns a list with all Vcrs on the FireWire bus.

Returns:
list<Vcr*> : return a stl-list with pointer to all Vcrs.

Definition at line 256 of file l1394_session.cpp.

References L1394::_FcpNode, L1394::_Vcr, and getAllNodes().

Referenced by findVcr(), and getAllAvcVcrs().

L1394::Session::getCard unsigned int  card_id  )  const
 

This method returns a pointer to the i'th card (beginning by 0).

Parameters:
card_id : the current card-id (value between 0..15).
Returns:
Card* : pointer to the Card object, if a card with this id exist, else NULL.

Definition at line 170 of file l1394_session.cpp.

Referenced by findNode(), getAllNodes(), main(), and nodeExist().

L1394::Session::getCardCount  )  const [inline]
 

This method returns the number of cards in your computer.

Returns:
int : integer with the card count.

Definition at line 269 of file l1394_session.h.

L1394::Session::getCardList  )  const
 

This method returns the card_array.

The card_array has size 16 and stores the pointer to all Card objects. If less than 16 cards the array is filled with NULL.

Returns:
list<const Card*> : Pointer to an array of size 16 with Card objects.

Definition at line 177 of file l1394_session.cpp.

const std::vector<std::string>& L1394::Session::getIsoDevices  )  const [inline]
 

Definition at line 271 of file l1394_session.h.

L1394::Session::getNode u_int64_t  guid  )  const [protected]
 

This method returns a pointer to a node specified by its guid return NULL, if node doesn't exist.

This method searches on all cards.

Parameters:
guid : u_int64_t value for the guid.
Returns:
Node* : pointer to the Node, if a node with this guid exist, else NULL.

Definition at line 166 of file l1394_session.cpp.

References L1394::internal::NodeContainer::getNodeContainer().

L1394::Session::getSession  )  [static, protected]
 

This method returns a pointer to the Session object.

If no session object exist, it is created.

Returns:
Session* : pointer to the Session object.

L1394::Session::nodeExist u_int64_t  guid  )  const
 

This method tests, if a node with a specific guid exist.

This method searches on all cards.

Parameters:
guid : u_int64_t for the guid of the node.
Returns:
bool : true if a node exist, else false.

Definition at line 198 of file l1394_session.cpp.

References getCard().

L1394::Session::removeEventHandle EventHandle  ) 
 

This method removes an EventHandle.

Definition at line 347 of file l1394_session.cpp.

References L1394::internal::Message::errorStream().

Referenced by SimpleEventHandle::~SimpleEventHandle().

L1394::Session::safeMode bool  mode = false,
int  delay = 30
[inline, static]
 

This method enables the safe-mode for the read and write functions.

By enabling safe mode the read, write and lock functions are delayed for some msecs. If you send a lot of asynchrone commands, a bus rest can occur.

Parameters:
mode : true enables safe-mode, false disables safe-mode
delay : how many msecs delayed between asynchronous commands.

Definition at line 479 of file l1394_session.h.

References L1394::internal::Transaction::setSafeMode().

L1394::Session::setDebugStream std::ostream *  output  )  [inline, static]
 

This method sets the debug output.

Parameters:
output : pointer to the output for debug messages.

Definition at line 446 of file l1394_session.h.

References L1394::Singleton< T, CreationPolicy, LifetimePolicy, ThreadingModel >::getInstance().

L1394::Session::setErrorStream std::ostream *  output  )  [inline, static]
 

This method sets the error output.

Parameters:
output : pointer to the output for debug messages.

Definition at line 461 of file l1394_session.h.

References L1394::Singleton< T, CreationPolicy, LifetimePolicy, ThreadingModel >::getInstance().

L1394::Session::setMessageStream std::ostream *  output  )  [inline, static]
 

This method sets the standard output.

Parameters:
output : pointer to the output for debug messages.

Definition at line 453 of file l1394_session.h.

References L1394::Singleton< T, CreationPolicy, LifetimePolicy, ThreadingModel >::getInstance().

L1394::Session::setWarningStream std::ostream *  output  )  [inline, static]
 

This method sets the error output.

Parameters:
output : pointer to the output for debug messages.

Definition at line 468 of file l1394_session.h.

References L1394::Singleton< T, CreationPolicy, LifetimePolicy, ThreadingModel >::getInstance().


Friends And Related Function Documentation

friend class L1394::CreateUsingNew< Session > [friend]
 

Definition at line 257 of file l1394_session.h.


Member Data Documentation

ThreadMutex L1394::Session::global_mutex [static]
 

Definition at line 508 of file l1394_session.cpp.

Referenced by Session().

bool L1394::Session::session_is_running = true [static]
 

Definition at line 507 of file l1394_session.cpp.

Referenced by Session().


The documentation for this class was generated from the following files:
Generated on Wed Aug 24 00:36:45 2005 for L1394 by doxygen 1.4.2
L1394 library (NMM) grahics.cs.uni-sb.de/~repplix/l1394_home/