Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

/root/resourcemonitord/resourcemonitord/IRMRegistration.h File Reference

#include "ISubsystemMonitor.h"
#include "Statistic.h"
#include "Monitor.h"

Go to the source code of this file.

Namespaces

namespace  SubsystemMonitor

Defines

#define CommonStatisticProxyIDstring   "1e14da1d-9a03-480f-9754-4940dd552646"
 CommonStatisticProxyIDstring is the UUID for the Common Statistic Library (CSL). More...


Define Documentation

#define CommonStatisticProxyIDstring   "1e14da1d-9a03-480f-9754-4940dd552646"
 

CommonStatisticProxyIDstring is the UUID for the Common Statistic Library (CSL).

IRMRegistration class contains methods for subsystems to call to register their class factories

A subsystem library is dynamically loaded by the daemon when its entry is read from the rmtab file. Each line in the rmtab file contains the universally-unique identifier (UUID) for the subsystem and the location in the file system of its shared library. When the subsystem library is linked, a global class constructor in the library is required to call the daemon's registration methods in the IRMRegistration class. The RMuid parameter must match universally-unique identifier found in the rmtab file. See the code below for an example of the subsystem registration process.

Note:
One library can register more than one subsystem. For every subsystem a library represents there must be an entry in rmtab and a corresponding set of IRMRegistration methods called with a matching universally-unique identifier. This can be done from a single global class contructor. New subsystems can obtain a UUID by running the utility uuidgen in /usr/bin.
See also:
SubsystemMonitor for debug note.

extern "C" {

SubsystemMonitor::ISubsystemMonitor * ISubsystemFactory(RMuid a_guid) {
    if( a_guid == g_registrationData.guid ) {
        SubsystemMonitor::ISubsystemMonitor * mp = 0;
        try {
            mp = new CSubsystemInfo(a_guid);
        }
        catch ( bad_alloc )
        {
            errno = ENOMEM;
        }
        return mp;
    }
    return 0;
}

SubsystemMonitor::Statistic * StatisticFactory(RMuid a_guid,
                                               rmID a_resourceid,
                                               rmID a_statid) {
    if( a_guid == g_registrationData.guid ) {
        class CProcess * cp = g_processControl.createCProcess(a_resourceid);
        if( cp == 0 )
            return 0;
        for( size_t i=0 ; i<RM_PROCESS_STATISTICS ; i++ )
            if( g_registrationData.statistics[i].id == a_statid ) {
                SubsystemMonitor::Statistic * sp = 0;
                try {
                    sp = new CProcessStatistic(cp, a_statid);
                }
                catch ( bad_alloc )
                {
                    errno = ENOMEM;
                }
                return sp;
            }
        g_processControl.deleteCProcess(cp);
    }
    return 0;
}
#ifdef  InlineProcessMonitor
SubsystemMonitor::Monitor *MonitorFactory(rmID a_mon,
                                          rmMonitorConfiguration a_config,
                                          RMuid a_monUID) {
    if( g_registrationData.guid == a_config.statisticKey.SubsystemId && a_mon == 0) {
        return  new CProcessMonitor(a_config.statisticKey.SubsystemId, a_config.statisticKey.ResourceId, a_config.statisticKey.StatisticId, a_mon);
    }
    return 0;
}
#endif  // InlineProcessMonitor

}   //extern "C"
}       // ProcessMonitor

#include <IRMRegistration.h>
class CProcessMonitorProxy
{
public:
    // this global constructor is required for successful registration with the resource monitor daemon
    CProcessMonitorProxy()
    {
        SubsystemMonitor::IRMRegistration::registerSubsystem(ProcessMonitor::g_registrationData.guid, &ProcessMonitor::ISubsystemFactory);
        SubsystemMonitor::IRMRegistration::registerStatistic(ProcessMonitor::g_registrationData.guid, &ProcessMonitor::StatisticFactory);
#ifdef  InlineProcessMonitor
        SubsystemMonitor::IRMRegistration::registerMonitor(ProcessMonitor::g_registrationData.guid, &ProcessMonitor::MonitorFactory);
#endif  // InlineProcessMonitor
    }
};
// our one instance of the proxy
CProcessMonitorProxy g_registerProcessMonitor;


Generated at Sat Sep 7 21:21:07 2002 for Resource Monitoring Facility by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001