00001 /*************************************************************************** 00002 l1394_nodefactory.h - description 00003 ------------------- 00004 begin : Wed Jan 31 2001 00005 copyright : (C) 2001-2004 by Michael Repplinger 00006 email : repplix@studcs.uni-sb.de 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #ifndef L1394_NODEFACTORY_H 00019 #define L1394_NODEFACTORY_H 00020 00021 #include "l1394_avcvcr.h" 00022 #include "l1394_avccamera.h" 00023 #include "l1394_message.h" 00024 #include "Thread.hpp" 00025 #include "libraw1394/raw1394.h" 00026 00027 namespace L1394{ 00028 00029 class Card; 00030 class FcpNode; 00031 class Node; 00032 namespace internal{ 00033 /*! \class NodeFactory 00034 * \brief This class creates L1394 node objects. 00035 * 00036 * This class creates the default L1394 node objects (Crad, DccCamera, FcpCamera and PhyNode) 00037 * and devices (AvcCamera, AvcVcr..). If you like to use your own L1394 Node 00038 * objects inherit from this class and rewrite the createNode(), createCard() and 00039 * createDevice() function. 00040 * 00041 * This class is designed as singelton. So if you use your own NodeFactory you must 00042 * instantiate the new factory before the Session object. The Session object calls 00043 * the method getFactory() and gets the new factory. 00044 * 00045 *@author Michael Repplinger 00046 */ 00047 00048 class NodeFactory { 00049 public: 00050 00051 /*! \fn getNodeFactory() 00052 * \brief This static method returns the pointer to the NodeFactory 00053 * 00054 * \return NodeFactory* : pointer to the NodeFactory. 00055 */ 00056 static NodeFactory* getNodeFactory(); 00057 00058 00059 /*! \fn ~NodeFactory() 00060 * \brief destructor 00061 */ 00062 virtual ~NodeFactory(); 00063 00064 00065 /*! \fn Node* createNode(Card* card, const u_int32_t node_id) 00066 * \brief This method creates the node-objects. 00067 * 00068 * If you like to create your own Node objects inherit from this class and 00069 * rewrite this function. 00070 * \param card : pointer to the Card object. 00071 * \param node_id : node_id of the new node. 00072 * \return Node*: pointer to the Node object. 00073 */ 00074 virtual Node* createNode(Card*, const u_int32_t); 00075 00076 00077 /*! \fn createCard(const u_int32_t card_id, const u_int32_t node_id, raw1394handle_t default_handle) 00078 * \brief This method instantiates the Card object. 00079 * 00080 * \param card_id : The card-id of the card. 00081 * \param node_id : The node-id of the card. 00082 * \param default_handle : pointer to the default_handle for the new card. 00083 * \return Card* : pointer to the Card object. 00084 */ 00085 virtual Card* createCard(const u_int32_t card_id, const u_int32_t node_id, raw1394handle_t default_handle); 00086 00087 /*! \fn createDevice(FcpNode* parent_node, int subunit_value) 00088 * \brief This method instantiates the Device objects for FcpNodes. 00089 * \param parent_node : pointer to the parent_node. 00090 * \param subunit_value : The subunit_value defines the subunit_type and subunit_id. 00091 */ 00092 virtual Device* createDevice(FcpNode*, int subunit_type); 00093 00094 protected: 00095 00096 NodeFactory(); 00097 00098 /*! \fn scanNode(Card* card, unsigned int node_id) 00099 * \brief scans a specific node and returns the type (AVC, DCC, ...) as integer 00100 * value (defined in class Node) 00101 * \param Card* card: pointer to the card object. 00102 * \param node_id: the actual node-id on the bus. 00103 * \return int : returns the node type as integer value. 00104 */ 00105 virtual NodeType scanNode(Card* c, unsigned int node_id); 00106 00107 private: 00108 static NodeFactory* factory; 00109 static Message* message; 00110 static ThreadMutex mutex; 00111 }; 00112 00113 }//end namespcae internal 00114 }//end namespace l1394 00115 #endif