LibreOffice Module framework (master) 1
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
framework::JobData Class Referencefinal

holds all necessary information about a job and handle it's configuration (if any exist!) @descr It can be used from different use cases as a container (or proxy) for all config data of a registered job. More...

#include <jobdata.hxx>

Classes

struct  TJob2DocEventBinding
 Some jobs can be registered to "logical events", which are generated on demand if another document event occurs. More...
 

Public Types

enum  EMode {
  E_UNKNOWN_MODE ,
  E_ALIAS ,
  E_SERVICE ,
  E_EVENT
}
 These values can be used to differe between jobs with and jobs without a configuration. More...
 
enum  EEnvironment {
  E_UNKNOWN_ENVIRONMENT ,
  E_EXECUTION ,
  E_DISPATCH ,
  E_DOCUMENTEVENT
}
 These values represent the environment type, in which a job can run. More...
 

Public Member Functions

 JobData (css::uno::Reference< css::uno::XComponentContext > xContext)
 standard ctor @descr It initialize this new instance. More...
 
 JobData (const JobData &rCopy)
 copy ctor @descr Sometimes such job data container must be moved from one using place to another one. More...
 
 ~JobData ()
 let this instance die @descr There is no chance any longer to work. More...
 
JobDataoperator= (const JobData &rCopy)
 operator for copying JobData instances @descr Sometimes such job data container must be moved from one using place to another one. More...
 
EMode getMode () const
 these functions provides access to our internal members @descr These member represent any information about the job and can be used from outside to e.g. More...
 
EEnvironment getEnvironment () const
 
OUString getEnvironmentDescriptor () const
 
OUString getService () const
 
OUString getEvent () const
 
css::uno::Sequence< css::beans::NamedValue > getConfig () const
 
std::vector< css::beans::NamedValue > getJobConfig () const
 
bool hasConfig () const
 return information, if this job is part of the global configuration package org.openoffice.Office.Jobs @descr Because jobs can be executed by the dispatch framework using a uno service name directly - an executed job must not have any configuration really. More...
 
bool hasCorrectContext (std::u16string_view rModuleIdent) const
 
void setEnvironment (EEnvironment eEnvironment)
 set a new environment descriptor for this job @descr It must(!) be done every time this container is initialized with new job data e.g. More...
 
void setAlias (const OUString &sAlias)
 initialize this instance as a job with configuration @descr They given alias can be used to address some configuration data. More...
 
void setService (const OUString &sService)
 initialize this instance as a job without configuration @descr This job has no configuration data. More...
 
void setEvent (const OUString &sEvent, const OUString &sAlias)
 initialize this instance with new job values. More...
 
void setJobConfig (std::vector< css::beans::NamedValue > &&lArguments)
 set the new job specific arguments @descr If a job finish his work, it can give us a new list of arguments (which will not interpreted by us). More...
 
void disableJob ()
 mark a job as non startable for further requests @descr We don't remove the configuration entry! We set a timestamp value only. More...
 

Static Public Member Functions

static std::vector< OUString > getEnabledJobsForEvent (const css::uno::Reference< css::uno::XComponentContext > &rxContext, std::u16string_view sEvent)
 
static void appendEnabledJobsForEvent (const css::uno::Reference< css::uno::XComponentContext > &rxContext, const OUString &sEvent, ::std::vector< JobData::TJob2DocEventBinding > &lJobs)
 

Private Member Functions

void impl_reset ()
 reset all internal structures @descr If someone recycles this instance, he can switch from one using mode to another one. More...
 

Private Attributes

css::uno::Reference< css::uno::XComponentContext > m_xContext
 reference to the uno service manager. More...
 
EMode m_eMode
 An instance of this class can be used in two different modes: More...
 
EEnvironment m_eEnvironment
 Because jobs can be bind to different mechanism inside office, a job should know inside which environment it runs. More...
 
OUString m_sAlias
 the alias name of this job. More...
 
OUString m_sService
 the uno implementation name of this job. More...
 
OUString m_sContext
 the module context list of this job. More...
 
OUString m_sEvent
 a job can be registered for an event. More...
 
std::vector< css::beans::NamedValue > m_lArguments
 job specific configuration items... unknown for us! It's read from the configuration. More...
 

Detailed Description

holds all necessary information about a job and handle it's configuration (if any exist!) @descr It can be used from different use cases as a container (or proxy) for all config data of a registered job.

But it doesn't implement any execute functionality!

Definition at line 40 of file jobdata.hxx.

Member Enumeration Documentation

◆ EEnvironment

These values represent the environment type, in which a job can run.

A job must known, from which binding it will be started. Because it's initialization data depends from that!

Enumerator
E_UNKNOWN_ENVIRONMENT 

indicates a missing initialization

E_EXECUTION 

this job is used by the global JobExecutor service

E_DISPATCH 

this job is used by the global dispatch framework

E_DOCUMENTEVENT 

this job is used by the global event broadcaster

Definition at line 64 of file jobdata.hxx.

◆ EMode

These values can be used to differe between jobs with and jobs without a configuration.

Of course an "unknown state" should be available too, to detect a missing initialization.

Enumerator
E_UNKNOWN_MODE 

indicates a missing initialization

E_ALIAS 

indicates a job with configuration (They alias represent the config key name.)

E_SERVICE 

indicates a job without configuration (The pure UNO implementation is used only.)

E_EVENT 

indicates a job with configuration, which was triggered by an event

Definition at line 48 of file jobdata.hxx.

Constructor & Destructor Documentation

◆ JobData() [1/2]

framework::JobData::JobData ( css::uno::Reference< css::uno::XComponentContext >  xContext)

standard ctor @descr It initialize this new instance.

But for real working it's necessary to call setAlias() or setService() later. Because we need the job data ...

Parameters
rxContextreference to the uno service manager

Definition at line 49 of file jobdata.cxx.

References impl_reset().

◆ JobData() [2/2]

framework::JobData::JobData ( const JobData rCopy)

copy ctor @descr Sometimes such job data container must be moved from one using place to another one.

Then a copy ctor and copy operator must be available.

Parameters
rCopythe original instance, from which we must copy all data

Definition at line 64 of file jobdata.cxx.

◆ ~JobData()

framework::JobData::~JobData ( )

let this instance die @descr There is no chance any longer to work.

We have to release all used resources and free used memory.

Definition at line 97 of file jobdata.cxx.

References impl_reset().

Member Function Documentation

◆ appendEnabledJobsForEvent()

void framework::JobData::appendEnabledJobsForEvent ( const css::uno::Reference< css::uno::XComponentContext > &  rxContext,
const OUString &  sEvent,
::std::vector< JobData::TJob2DocEventBinding > &  lJobs 
)
static

Definition at line 419 of file jobdata.cxx.

References getEnabledJobsForEvent(), and i.

◆ disableJob()

void framework::JobData::disableJob ( )

mark a job as non startable for further requests @descr We don't remove the configuration entry! We set a timestamp value only.

And there exist two of them: one for an administrator... and one for the current user. We change it for the user layer only. So this JobDispatch can't be started any more... till the administrator change his timestamp. That can be useful for post setup scenarios, which must run one time only.

Note: This method don't do anything, if this represented job doesn't have a configuration!

Definition at line 366 of file jobdata.cxx.

References framework::ConfigAccess::cfg(), framework::ConfigAccess::close(), framework::Converter::convert_DateTime2ISO8601(), framework::ConfigAccess::E_CLOSED, E_EVENT, framework::ConfigAccess::E_READWRITE, framework::ConfigAccess::getMode(), m_eMode, m_sAlias, m_sEvent, m_xContext, framework::ConfigAccess::open(), DateTime::SYSTEM, and utl::wrapConfigurationElementName().

◆ getConfig()

css::uno::Sequence< css::beans::NamedValue > framework::JobData::getConfig ( ) const

Definition at line 328 of file jobdata.cxx.

References E_ALIAS, m_eMode, m_sAlias, m_sContext, and m_sService.

◆ getEnabledJobsForEvent()

std::vector< OUString > framework::JobData::getEnabledJobsForEvent ( const css::uno::Reference< css::uno::XComponentContext > &  rxContext,
std::u16string_view  sEvent 
)
static

◆ getEnvironment()

JobData::EEnvironment framework::JobData::getEnvironment ( ) const

Definition at line 286 of file jobdata.cxx.

References m_eEnvironment.

◆ getEnvironmentDescriptor()

OUString framework::JobData::getEnvironmentDescriptor ( ) const

Definition at line 291 of file jobdata.cxx.

References E_DISPATCH, E_DOCUMENTEVENT, E_EXECUTION, and m_eEnvironment.

◆ getEvent()

OUString framework::JobData::getEvent ( ) const

Definition at line 318 of file jobdata.cxx.

References m_sEvent.

◆ getJobConfig()

std::vector< css::beans::NamedValue > framework::JobData::getJobConfig ( ) const

Definition at line 323 of file jobdata.cxx.

References m_lArguments.

◆ getMode()

JobData::EMode framework::JobData::getMode ( ) const

these functions provides access to our internal members @descr These member represent any information about the job and can be used from outside to e.g.

start a job.

Definition at line 281 of file jobdata.cxx.

References m_eMode.

◆ getService()

OUString framework::JobData::getService ( ) const

Definition at line 313 of file jobdata.cxx.

References m_sService.

◆ hasConfig()

bool framework::JobData::hasConfig ( ) const

return information, if this job is part of the global configuration package org.openoffice.Office.Jobs @descr Because jobs can be executed by the dispatch framework using a uno service name directly - an executed job must not have any configuration really.

Such jobs must provide the right interfaces only! But after finishing jobs can return some information (e.g. for updating her configuration ...). We must know if such request is valid or not then.

Returns
sal_True if the represented job is part of the underlying configuration package.

Definition at line 351 of file jobdata.cxx.

References E_ALIAS, E_EVENT, and m_eMode.

◆ hasCorrectContext()

bool framework::JobData::hasCorrectContext ( std::u16string_view  rModuleIdent) const

Definition at line 434 of file jobdata.cxx.

References m_sContext, and nIndex.

◆ impl_reset()

void framework::JobData::impl_reset ( )
private

reset all internal structures @descr If someone recycles this instance, he can switch from one using mode to another one.

But then we have to reset all currently used information. Otherwise we mix it and they can make trouble.

But note: that does not set defaults for internal used members, which does not relate to any job property! e.g. the reference to the global uno service manager. Such information is used for internal processes only and are necessary for our work.

Definition at line 532 of file jobdata.cxx.

References E_UNKNOWN_ENVIRONMENT, E_UNKNOWN_MODE, m_eEnvironment, m_eMode, m_lArguments, m_sAlias, m_sContext, m_sEvent, and m_sService.

Referenced by JobData(), setAlias(), setService(), and ~JobData().

◆ operator=()

JobData & framework::JobData::operator= ( const JobData rCopy)

operator for copying JobData instances @descr Sometimes such job data container must be moved from one using place to another one.

Then a copy ctor and copy operator must be available.

Parameters
rCopythe original instance, from which we must copy all data

Definition at line 78 of file jobdata.cxx.

References m_eEnvironment, m_eMode, m_lArguments, m_sAlias, m_sContext, m_sEvent, and m_sService.

◆ setAlias()

void framework::JobData::setAlias ( const OUString &  sAlias)

initialize this instance as a job with configuration @descr They given alias can be used to address some configuration data.

We read it and fill our internal structures. Of course old information will be lost doing so.

Parameters
sAliasthe alias name of this job, used to locate job properties inside cfg

Definition at line 111 of file jobdata.cxx.

References framework::ConfigAccess::cfg(), framework::ConfigAccess::close(), E_ALIAS, framework::ConfigAccess::E_CLOSED, framework::ConfigAccess::E_READONLY, framework::ConfigAccess::getMode(), i, impl_reset(), m_eMode, m_lArguments, m_sAlias, m_sContext, m_sService, m_xContext, Name, nCount, framework::ConfigAccess::open(), and utl::wrapConfigurationElementName().

Referenced by setEvent().

◆ setEnvironment()

void framework::JobData::setEnvironment ( EEnvironment  eEnvironment)

set a new environment descriptor for this job @descr It must(!) be done every time this container is initialized with new job data e.g.

: setAlias()/setEvent()/setService() ... Otherwise the environment will be unknown!

Definition at line 271 of file jobdata.cxx.

References m_eEnvironment.

◆ setEvent()

void framework::JobData::setEvent ( const OUString &  sEvent,
const OUString &  sAlias 
)

initialize this instance with new job values.

@descr It reads automatically all properties of the specified job (using it's alias name) and "register it" for the given event. This registration will not be validated against the underlying configuration! (That must be done from outside. Because the caller must have the configuration already open to get the values for sEvent and sAlias! And doing so it can perform only, if the time stamp values are read outside too. Further it makes no sense to initialize and start a disabled job. So this initialization method will be called for enabled jobs only.)

Parameters
sEventthe triggered event, for which this job should be started
sAliasmark the required job inside event registration list

Definition at line 203 of file jobdata.cxx.

References E_EVENT, m_eMode, m_sEvent, and setAlias().

◆ setJobConfig()

void framework::JobData::setJobConfig ( std::vector< css::beans::NamedValue > &&  lArguments)

set the new job specific arguments @descr If a job finish his work, it can give us a new list of arguments (which will not interpreted by us).

We write it back to the configuration only (if this job has its own configuration!). So a job can have persistent data without implementing anything or define own config areas for that.

Parameters
lArgumentslist of arguments, which should be set for this job

Definition at line 225 of file jobdata.cxx.

References framework::ConfigAccess::cfg(), framework::ConfigAccess::close(), E_ALIAS, framework::ConfigAccess::E_CLOSED, framework::ConfigAccess::E_READWRITE, framework::ConfigAccess::getMode(), i, m_eMode, m_lArguments, m_sAlias, m_xContext, nCount, framework::ConfigAccess::open(), and utl::wrapConfigurationElementName().

◆ setService()

void framework::JobData::setService ( const OUString &  sService)

initialize this instance as a job without configuration @descr This job has no configuration data.

We have to forget all old information and set only some of them new, so this instance can work.

Parameters
sServicethe uno service name of this "non configured" job

Definition at line 176 of file jobdata.cxx.

References E_SERVICE, impl_reset(), m_eMode, and m_sService.

Member Data Documentation

◆ m_eEnvironment

EEnvironment framework::JobData::m_eEnvironment
private

Because jobs can be bind to different mechanism inside office, a job should know inside which environment it runs.

E.g. a job can be executed by the global JobExecutor service (triggered by an event) or e.g. as part of the global dispatch framework (triggered by an UI control e.g. a menu entry).

Definition at line 126 of file jobdata.hxx.

Referenced by getEnvironment(), getEnvironmentDescriptor(), impl_reset(), operator=(), and setEnvironment().

◆ m_eMode

EMode framework::JobData::m_eMode
private

An instance of this class can be used in two different modes:

  • as a configured job
  • as a job without any configuration First mode is triggered by an alias, which points to the configuration entries. Second mode is specified by a uno service or implementation name. Then we do the same things (use the same interfaces) but don't handle any configuration data. The effect: This mode can be detected by this member.

Definition at line 118 of file jobdata.hxx.

Referenced by disableJob(), getConfig(), getMode(), hasConfig(), impl_reset(), operator=(), setAlias(), setEvent(), setJobConfig(), and setService().

◆ m_lArguments

std::vector< css::beans::NamedValue > framework::JobData::m_lArguments
private

job specific configuration items... unknown for us! It's read from the configuration.

Don't set it from outside!

Definition at line 162 of file jobdata.hxx.

Referenced by getJobConfig(), impl_reset(), operator=(), setAlias(), and setJobConfig().

◆ m_sAlias

OUString framework::JobData::m_sAlias
private

the alias name of this job.

Is used as entry of configuration set for job registration, to find all necessary properties of it...

Definition at line 133 of file jobdata.hxx.

Referenced by disableJob(), getConfig(), impl_reset(), operator=(), setAlias(), and setJobConfig().

◆ m_sContext

OUString framework::JobData::m_sContext
private

the module context list of this job.

It's read from the configuration. Don't set it from outside!

Definition at line 145 of file jobdata.hxx.

Referenced by getConfig(), hasCorrectContext(), impl_reset(), operator=(), and setAlias().

◆ m_sEvent

OUString framework::JobData::m_sEvent
private

a job can be registered for an event.

It can be an empty value! But it will be set from outside any times. Because it's not clear which job this instance should represent if an event (instead of an alias) comes in. Because there can be multiple registrations for this event. We use this information only, to merge it with the job specific arguments. A job can be called so, with a) its own config data and b) some dynamic environment data.

Definition at line 156 of file jobdata.hxx.

Referenced by disableJob(), getEvent(), impl_reset(), operator=(), and setEvent().

◆ m_sService

OUString framework::JobData::m_sService
private

the uno implementation name of this job.

It's read from the configuration. Don't set it from outside!

Definition at line 139 of file jobdata.hxx.

Referenced by getConfig(), getService(), impl_reset(), operator=(), setAlias(), and setService().

◆ m_xContext

css::uno::Reference< css::uno::XComponentContext > framework::JobData::m_xContext
private

reference to the uno service manager.

We need it for creating of own uno services ... e.g. for opening the configuration.

Definition at line 106 of file jobdata.hxx.

Referenced by disableJob(), setAlias(), and setJobConfig().


The documentation for this class was generated from the following files: