(file) Return to ModuleController.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/ModuleController.h between version 1.48 and 1.49

version 1.48, 2006/07/25 19:11:15 version 1.49, 2006/07/28 19:50:55
Line 34 
Line 34 
 // Modified By: Amit K Arora, IBM (amita@in.ibm.com) // Modified By: Amit K Arora, IBM (amita@in.ibm.com)
 //              David Dillard, VERITAS Software Corp. //              David Dillard, VERITAS Software Corp.
 //                  (david.dillard@veritas.com) //                  (david.dillard@veritas.com)
   //              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #ifndef Pegasus_Module_Controller_h  #ifndef Pegasus_ModuleController_h
 #define Pegasus_Module_Controller_h  #define Pegasus_ModuleController_h
  
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
   #include <Pegasus/Common/Linkage.h>
 #include <Pegasus/Common/Constants.h> #include <Pegasus/Common/Constants.h>
   #include <Pegasus/Common/List.h>
 #include <Pegasus/Common/Message.h> #include <Pegasus/Common/Message.h>
 #include <Pegasus/Common/InternalException.h>  
 #include <Pegasus/Common/IPC.h>  
 #include <Pegasus/Common/Thread.h>  
 #include <Pegasus/Common/AsyncOpNode.h>  
 #include <Pegasus/Common/Cimom.h>  
 #include <Pegasus/Common/CimomMessage.h>  
 #include <Pegasus/Common/MessageQueueService.h> #include <Pegasus/Common/MessageQueueService.h>
 #include <Pegasus/Common/Linkage.h>  #include <Pegasus/Common/AsyncOpNode.h>
 #include <Pegasus/Common/AutoPtr.h> #include <Pegasus/Common/AutoPtr.h>
 #include <Pegasus/Common/List.h>  
   
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
 class ModuleController;  class PEGASUS_COMMON_LINKAGE RegisteredModuleHandle : public Linkable
   
   
 class PEGASUS_COMMON_LINKAGE pegasus_module : public Linkable  
 {  
 private:  
     class module_rep  
     {     {
     public:     public:
         module_rep(ModuleController *controller,      RegisteredModuleHandle(
                const String & name,                const String & name,
                void *module_address,                void *module_address,
                Message * (*receive_message)(Message *, void *),                Message * (*receive_message)(Message *, void *),
                void (*async_callback)(Uint32, Message *, void *),          void (*async_callback)(Uint32, Message *, void *));
                void (*shutdown_notify)(Uint32 code, void *));  
   
         ~module_rep();  
  
         void reference()      virtual ~RegisteredModuleHandle();
         {  
             _reference_count++;  
         }  
  
         void dereference()      const String & get_name() const;
         {  
             _reference_count--;  
         }  
   
         Uint32 reference_count() const  
         {  
             return _reference_count.get();  
         }  
   
         const String& get_name() const throw()  
         {  
             return _name;  
         }  
  
         void *get_module_address() const  private:
         {  
             return _module_address;  
         }  
  
         Message * module_receive_message(Message *msg);      RegisteredModuleHandle();
       RegisteredModuleHandle(const RegisteredModuleHandle&);
       RegisteredModuleHandle& operator=(const RegisteredModuleHandle&);
  
       Message* _receive_message(Message* msg);
         void _send_async_callback(Uint32 msg_handle, Message *msg, void *parm);         void _send_async_callback(Uint32 msg_handle, Message *msg, void *parm);
  
         void _send_shutdown_notify();  
   
         void lock()  
         {  
             _thread_safety.lock(pegasus_thread_self());  
         }  
   
         void unlock()  
         {  
             _thread_safety.unlock();  
         }  
   
     private:  
         module_rep();  
         module_rep(const module_rep&);  
         module_rep & operator=(const module_rep & rep);  
   
         Mutex _thread_safety;  
         // Don't make this an AutoPtr. Refer to bug 3502  
         ModuleController* _controller;  
         String _name;         String _name;
         AtomicInt _reference_count;  
         AtomicInt _shutting_down;  
   
         void *_module_address;         void *_module_address;
         Message * (*_receive_message)(Message *, void *);      Message* (*_module_receive_message)(Message *, void *);
         void (*_async_callback)(Uint32, Message *, void *);         void (*_async_callback)(Uint32, Message *, void *);
         void (*_shutdown_notify)(Uint32 code, void *);  
   
         static Message * default_receive_message(Message *msg, void *inst)  
         {  
             throw NotImplemented("Module Receive");  
             return 0;  
         }  
   
         static void default_async_callback(Uint32 handle, Message *msg, void *inst)  
         {  
             throw NotImplemented("Module Async Receive");  
         }  
   
         static void default_shutdown_notify(Uint32 code, void *inst)  
         {  
             // Intentionally left blank  
         }  
   
         static Message * closed_receive_message(Message *msg, void *inst)  
         {  
             throw ModuleClosed();  
             return 0;  
         }  
   
         static void closed_async_callback(Uint32 handle, Message *msg, void *inst)  
         {  
             throw ModuleClosed();  
         }  
   
         friend class ModuleController;  
     };  
   
 public:  
     pegasus_module(ModuleController *controller,  
              const String &id,  
              void *module_address,  
              Message * (*receive_message)(Message *, void *),  
              void (*async_callback)(Uint32, Message *, void *),  
              void (*shutdown_notify)(Uint32 code, void *));  
   
     pegasus_module(const pegasus_module & mod);  
     pegasus_module & operator= (const pegasus_module & mod);  
   
     virtual ~pegasus_module();  
   
     Boolean operator == (const String &  mod) const;  
   
     const String & get_name() const;  
   
     // introspection interface  
     Boolean query_interface(const String & class_id, void **object_ptr) const;  
   
 private:  
   
     AutoPtr<module_rep> _rep;//PEP101  
   
     pegasus_module()  
     {  
     }  
   
     Boolean _rcv_msg(Message *);  
     Message * _receive_message(Message *msg);  
     void _send_async_callback(Uint32 msg_handle, Message *msg, void *);  
     void _send_shutdown_notify();  
     Boolean _shutdown();  
   
     void reference()  
     {  
         _rep->reference();  
     }  
   
     void dereference()  
     {  
         _rep->dereference();  
     }  
  
     friend class ModuleController;     friend class ModuleController;
 }; };
Line 219 
Line 91 
     class callback_handle     class callback_handle
     {     {
     public:     public:
         callback_handle(pegasus_module * module, void *parm)          callback_handle(RegisteredModuleHandle* module, void* parm)
            : _module(module), _parm(parm)            : _module(module), _parm(parm)
         {         {
         }         }
Line 227 
Line 99 
         ~callback_handle()         ~callback_handle()
         {         {
             if( _module->get_name() == String(PEGASUS_MODULENAME_TEMP) )             if( _module->get_name() == String(PEGASUS_MODULENAME_TEMP) )
                 // delete _module;  
                 _module.reset();                 _module.reset();
         }         }
  
         AutoPtr<pegasus_module> _module;//PEP101          AutoPtr<RegisteredModuleHandle> _module;
         void *_parm;         void *_parm;
     };     };
  
 public: public:
     ModuleController(const char *name);     ModuleController(const char *name);
 /*       ModuleController(const char *name,  */  
 /*             Sint16 min_threads,  */  
 /*             Sint16 max_threads, */  
 /*             struct timeval & create_thread, */  
 /*             struct timeval & destroy_thread); */  
  
     ~ModuleController();     ~ModuleController();
  
     // module api     // module api
     // @exception AlreadyExistsException     // @exception AlreadyExistsException
     // @exception IncompatibleTypesException     // @exception IncompatibleTypesException
     static ModuleController & register_module(const String & controller_name,      static ModuleController& register_module(
           const String & controller_name,
                     const String & module_name,                     const String & module_name,
                     void *module_address,                     void *module_address,
                     Message * (*receive_message)(Message *, void *),                     Message * (*receive_message)(Message *, void *),
                     void (*async_callback)(Uint32, Message *, void *),                     void (*async_callback)(Uint32, Message *, void *),
                     void (*shutdown_notify)(Uint32, void *),          RegisteredModuleHandle** instance = 0);
                     pegasus_module **instance = NULL);  
  
     // @exception Permission     // @exception Permission
     Boolean deregister_module(const String & module_name);     Boolean deregister_module(const String & module_name);
  
     // @exception Permission     // @exception Permission
     Uint32 find_service(const pegasus_module & handle, const String & name);      Uint32 find_service(
           const RegisteredModuleHandle& handle,
           const String& name);
  
     // @exception Permission     // @exception Permission
     // @exception IPCException     // @exception IPCException
     Uint32 find_module_in_service(const pegasus_module & handle,      Uint32 find_module_in_service(
                     const String & module_name);          const RegisteredModuleHandle& handle,
   
     // @exception Permission  
     pegasus_module * get_module_reference(const pegasus_module & my_handle,  
                     const String & module_name);                     const String & module_name);
  
     // send a message to another service     // send a message to another service
     // @exception Permission     // @exception Permission
     // @exception IPCException     // @exception IPCException
     AsyncReply *ModuleSendWait(const pegasus_module & handle,      AsyncReply* ModuleSendWait(
           const RegisteredModuleHandle& handle,
                     Uint32 destination_q,                     Uint32 destination_q,
                     AsyncRequest *request);                     AsyncRequest *request);
  
Line 282 
Line 148 
     // @exception Permission     // @exception Permission
     // @exception DeadLock     // @exception DeadLock
     // @exception IPCException     // @exception IPCException
     AsyncReply *ModuleSendWait(const pegasus_module & handle,      AsyncReply* ModuleSendWait(
           const RegisteredModuleHandle& handle,
                     Uint32 destination_q,                     Uint32 destination_q,
                     const String & destination_module,                     const String & destination_module,
                     AsyncRequest *message);                     AsyncRequest *message);
Line 291 
Line 158 
     // @exception Permission     // @exception Permission
     // @exception DeadLock     // @exception DeadLock
     // @exception IPCException     // @exception IPCException
     Boolean ModuleSendAsync(const pegasus_module & handle,      Boolean ModuleSendAsync(
           const RegisteredModuleHandle& handle,
                     Uint32 msg_handle,                     Uint32 msg_handle,
                     Uint32 destination_q,                     Uint32 destination_q,
                     AsyncRequest *message,                     AsyncRequest *message,
Line 300 
Line 168 
     // send an async message to another module via another service     // send an async message to another module via another service
     // @exception Permission     // @exception Permission
     // @exception IPCException     // @exception IPCException
     Boolean ModuleSendAsync(const pegasus_module & handle,      Boolean ModuleSendAsync(
           const RegisteredModuleHandle& handle,
                     Uint32 msg_handle,                     Uint32 msg_handle,
                     Uint32 destination_q,                     Uint32 destination_q,
                     const String & destination_module,                     const String & destination_module,
Line 309 
Line 178 
  
     // @exception Permission     // @exception Permission
     // @exception IPCException     // @exception IPCException
     Boolean ModuleSendForget(const pegasus_module & handle,      Boolean ModuleSendForget(
           const RegisteredModuleHandle& handle,
                     Uint32 destination_q,                     Uint32 destination_q,
                     AsyncRequest *message);                     AsyncRequest *message);
  
     // @exception Permission     // @exception Permission
     // @exception IPCException     // @exception IPCException
     Boolean ModuleSendForget(const pegasus_module & handle,      Boolean ModuleSendForget(
           const RegisteredModuleHandle & handle,
                     Uint32 destination_q,                     Uint32 destination_q,
                     const String & destination_module,                     const String & destination_module,
                     AsyncRequest *message);                     AsyncRequest *message);
  
     Boolean verify_handle(pegasus_module *);      Boolean verify_handle(RegisteredModuleHandle *);
  
     static ModuleController* getModuleController();     static ModuleController* getModuleController();
  
Line 328 
Line 199 
     // @exception Permission     // @exception Permission
     // @exception IPCException     // @exception IPCException
     AsyncReply *ClientSendWait(     AsyncReply *ClientSendWait(
                     Uint32 destination_q, AsyncRequest *request);          Uint32 destination_q,
           AsyncRequest* request);
  
     // send a message to another module via another service     // send a message to another module via another service
     // @exception Permission     // @exception Permission
Line 384 
Line 256 
     class _module_lock     class _module_lock
     {     {
     public:     public:
         _module_lock(List<pegasus_module, RecursiveMutex> * list)          _module_lock(List<RegisteredModuleHandle, RecursiveMutex> * list)
            :_list(list)            :_list(list)
         {         {
            _list->lock();            _list->lock();
Line 397 
Line 269 
  
     private:     private:
         _module_lock();         _module_lock();
         List<pegasus_module, RecursiveMutex> * _list;          List<RegisteredModuleHandle, RecursiveMutex> * _list;
     };     };
  
  
  
     static void _async_handleEnqueue(AsyncOpNode *h, MessageQueue *q, void *parm);     static void _async_handleEnqueue(AsyncOpNode *h, MessageQueue *q, void *parm);
     List<pegasus_module, RecursiveMutex> _modules;      List<RegisteredModuleHandle, RecursiveMutex> _modules;
     AsyncReply *_send_wait(Uint32, AsyncRequest *);     AsyncReply *_send_wait(Uint32, AsyncRequest *);
     AsyncReply *_send_wait(Uint32, const String &, AsyncRequest *);     AsyncReply *_send_wait(Uint32, const String &, AsyncRequest *);
  
Line 416 
Line 288 
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END
  
 #endif // Pegasus_Module_Controller_H  #endif // Pegasus_ModuleController_h


Legend:
Removed from v.1.48  
changed lines
  Added in v.1.49

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2