(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.4 and 1.58.8.1

version 1.4, 2002/03/20 21:25:49 version 1.58.8.1, 2011/10/11 18:18:08
Line 1 
Line 1 
 //%////-*-c++-*-////////////////////////////////////////////////////////////////  //%LICENSE////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM  // Licensed to The Open Group (TOG) under one or more contributor license
   // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
   // this work for additional information regarding copyright ownership.
   // Each contributor licenses this file to you under the OpenPegasus Open
   // Source License; you may not use this file except in compliance with the
   // License.
   //
   // Permission is hereby granted, free of charge, to any person obtaining a
   // copy of this software and associated documentation files (the "Software"),
   // to deal in the Software without restriction, including without limitation
   // the rights to use, copy, modify, merge, publish, distribute, sublicense,
   // and/or sell copies of the Software, and to permit persons to whom the
   // Software is furnished to do so, subject to the following conditions:
   //
   // The above copyright notice and this permission notice shall be included
   // in all copies or substantial portions of the Software.
   //
   // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
   // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
   // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
   // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
   // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
   // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy  //////////////////////////////////////////////////////////////////////////
 // of this software and associated documentation files (the "Software"), to  
 // deal in the Software without restriction, including without limitation the  
 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or  
 // sell copies of the Software, and to permit persons to whom the Software is  
 // furnished to do so, subject to the following conditions:  
 //  
 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN  
 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED  
 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT  
 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR  
 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT  
 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN  
 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION  
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  
 //  
 //==============================================================================  
 //  
 // Author: Mike Day (mdday@us.ibm.com) <<< Wed Mar 13 20:49:40 2002 mdd >>>  
 //  
 // Modified By:  
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #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/List.h>
 #include <Pegasus/Common/Message.h> #include <Pegasus/Common/Message.h>
 #include <Pegasus/Common/Exception.h>  #include <Pegasus/Common/CIMMessage.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>
 PEGASUS_NAMESPACE_BEGIN  #include <Pegasus/Common/AsyncOpNode.h>
   #include <Pegasus/Common/AutoPtr.h>
 class ModuleController;  #include <Pegasus/Common/CIMMessage.h>
   
   
 class PEGASUS_COMMON_LINKAGE pegasus_module  
 {  
       class  module_rep;  
   
    public:  
   
       pegasus_module(ModuleController *controller,  
                      const String &id,  
                      void *module_address,  
                      void (*_async_callback)(Uint32, Message *)) ;  
   
       pegasus_module(const pegasus_module & mod);  
   
   
       virtual ~pegasus_module();  
   
       pegasus_module & operator= (const pegasus_module & mod);  
       Boolean operator == (const pegasus_module *mod) const;  
       Boolean operator == (const pegasus_module & mod) const ;  
       Boolean operator == (const String &  mod) const;  
       Boolean operator == (const void *mod) const;  
   
       const String & get_name(void);  
   
       // introspection interface  
       Boolean query_interface(String & class_id, void **object_ptr) ;  
   
    private:  
   
       module_rep *_rep;  
   
       pegasus_module(void);  
       virtual Boolean _rcv_msg(Message *) = 0;  
       void _send_async_callback(Uint32 msg_handle, Message *msg) ;  
   
       virtual Boolean _shutdown(Uint32) = 0;  
   
       virtual Uint32 reference(void) { _reference_count++; }  
       virtual Uint32 dereference(void)  { _reference_count--; }  
   
       friend class ModuleController;  
 };  
  
   PEGASUS_NAMESPACE_BEGIN
  
 class PEGASUS_COMMON_LINKAGE pegasus_module::module_rep  class PEGASUS_COMMON_LINKAGE RegisteredModuleHandle : public Linkable
 { {
    public:    public:
       module_rep(ModuleController *controller,      RegisteredModuleHandle(
                  const String & name,                  const String & name,
                  void *module_address,                  void *module_address,
                  void (*async_callback)(Uint32, Message *))          Message* (*receive_message)(Message *, void *));
          : _controller(controller),  
            _name(name),  
            _reference_count(1),  
            _module_address(module_address),  
            _async_callback(async_callback)  
       {  
   
       }  
   
       virtual ~module_rep(void)  
       {  
   
       }  
   
   
       Boolean operator == (const module_rep *rep) const  
       {  
          if (rep == this )  
             return true;  
          return false;  
       }  
   
       Boolean operator == (const module_rep &rep) const  
       {  
          if (rep == *this)  
             return true;  
          return false;  
       }  
   
       Boolean operator == (void *rep) const  
       {  
          if ( (void *)this == rep )  
             return true;  
          return false;  
       }  
   
  
       virtual ~RegisteredModuleHandle();
  
       const String& get_name() const;
  
    private:    private:
       module_rep(void);  
       module_rep(const module_rep & );  
       module_rep& operator= (const module_rep & );  
  
       RegisteredModuleHandle();
       RegisteredModuleHandle(const RegisteredModuleHandle&);
       RegisteredModuleHandle& operator=(const RegisteredModuleHandle&);
  
       ModuleController *_controller;      Message* _receive_message(Message* msg);
       String _name;       String _name;
       AtomicInt _reference_count;  
       void *_module_address;       void *_module_address;
       void (*_async_callback)(Uint32, Message *);      Message* (*_module_receive_message)(Message *, void *);
   
       friend class ModuleController;       friend class ModuleController;
 }; };
  
  
 class PEGASUS_COMMON_LINKAGE ModuleController : public MessageQueueService class PEGASUS_COMMON_LINKAGE ModuleController : public MessageQueueService
 { {
   
    public:    public:
       typedef MesageQueueService Base;      typedef MessageQueueService Base;
       ModuleController(const char *name);
  
       ModuleController(const char *name, Uint32 queueID);      ~ModuleController();
       virtual ~ModuleController(void);  
  
       // module api      void register_module(
       ModuleController & register_module(const String & module_name,          const String& module_name,
                                          void *module_address,                                          void *module_address,
                                          void (*async_callback)(Uint32, Message *));          Message* (*receive_message)(Message *, void *));
  
       deregister_module(const String & module_name);      static ModuleController* getModuleController();
   
       Uint32 find_service(pegasus_module & handle, String & name);  
       String & find_service(pegasus_module & handle, Uint32 queue_id);  
   
       pegasus_module & get_module_reference(pegasus_module & handle, String & name);  
   
       // send a message to another service  
       Message *ModuleSendWait(pegasus_module & handle,  
                               Uint32 destination_q,  
                               Message *message);  
  
       // send a message to another module via another service      static  void indicationCallback(
       Message *ModuleSendWait(pegasus_module & handle,          CIMProcessIndicationRequestMessage* request);
                               Uint32 destination_q,  
                               String & destination_module,  
                               Message *message);  
  
       // send a message to another service       // send a message to another service
       Boolean ModuleSendAsync(pegasus_module & handle,      AsyncReply* ClientSendWait(
                               Uint32 msg_handle,  
                               Uint32 destination_q,                               Uint32 destination_q,
                               Message *message);          AsyncRequest* request);
  
       // send a message to another module via another service      Boolean ClientSendForget(
       Boolean ModuleSendAsync(pegasus_module & handle,  
                               Uint32 msg_handle,  
                               Uint32 destination_q,                               Uint32 destination_q,
                               String & destination_module,          AsyncRequest* message);
                               Message *message);  
   
       Uint32 blocking_thread_exec(pegasus_module & handle,  
                                   PEGASUS_THREAD_RETURN (PEGASUS_THREAD_CDECL *thread_func)(void *),  
                                   void *parm);  
       Uint32 async_thread_exec(pegasus_module & handle,  
                                PEGASUS_THREAD_RETURN (PEGASUS_THREAD_CDECL *thread_func)(void *),  
                                void *parm);  
  
    protected:    protected:
       // ATTN-RK-P2-20010322:  These methods are pure virtual in superclass
       virtual void handleEnqueue() {}
       virtual void handleEnqueue(Message *message);
       virtual void _handle_async_request(AsyncRequest *rq);
       virtual void _handle_async_callback(AsyncOpNode *op);
  
    private:    private:
       static void _indicationDeliveryRoutine(
       DQueue<pegasus_module> _modules;          CIMProcessIndicationRequestMessage* request);
       ThreadPool _thread_pool;      typedef List<RegisteredModuleHandle, Mutex> RegisteredModulesList;
       RegisteredModulesList _modules;
 }; };
  
   
 pegasus_module(const pegasus_module & mod)  
 {  
    (mod._rep->_reference_count)++;  
    _rep = mod._rep;  
 }  
   
 virtual ~pegasus_module()  
 {  
    if( 0 == (_rep->_reference_count.value()))  
       delete _rep;  
   
 }  
   
   
 pegasus_module & pegasus_module::operator= (const pegasus_module & mod)  
 {  
    (mod._rep->_reference_count)++;  
    if ( ((rep->_reference_count)--) == 0 )  
       delete rep;  
    _rep = mod._rep;  
    return *this;  
 }  
   
 Boolean pegasus_module::operator== (const pegasus_module *mod) const  
 {  
    if(mod->_rep == _rep)  
       return true;  
    return false;  
 }  
   
   
 Boolean pegasus_module::operator== (const pegasus_module & mod) const  
 {  
    if( mod._rep == _rep )  
       return true;  
    return false;  
   
 }  
   
 Boolean pegasus_module::operator == (const String &  mod) const  
 {  
    if(_rep->_name == mod)  
       return true;  
    return false;  
 }  
   
   
 Boolean pegasus_module::operator == (const void *mod) const  
 {  
    if ( (reinterpret_cast<pegasus_module *>(mod))->_rep == _rep)  
       return true;  
    return false;  
 }  
   
 Boolean pegasus_module::operator == (const void *mod) const  
 {  
    if ( (reinterpret_cast<pegasus_module *>(mod))->_rep == _rep)  
       return true;  
    return false;  
 }  
   
   
   
   
   
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END
  
   #endif // Pegasus_ModuleController_h
 #endif // Pegasus_Module_Controller_H  


Legend:
Removed from v.1.4  
changed lines
  Added in v.1.58.8.1

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2