| 1 | package RWDE::Configuration_content; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | |||
| 5 | use Error qw(:try); | ||
| 6 | use YAML qw(LoadFile); | ||
| 7 | |||
| 8 | use RWDE::Exceptions; | ||
| 9 | |||
| 10 | use base qw(RWDE::RObject); | ||
| 11 | |||
| 12 | our (@fieldnames, %fields, %static_fields, %modifiable_fields, @static_fieldnames, @modifiable_fieldnames); | ||
| 13 | |||
| 14 | use vars qw($VERSION); | ||
| 15 | $VERSION = sprintf "%d", q$Revision: 561 $ =~ /(\d+)/; | ||
| 16 | |||
| 17 | =pod | ||
| 18 | |||
| 19 | =head1 RWDE::Configuration_content | ||
| 20 | |||
| 21 | =cut | ||
| 22 | |||
| 23 | =head2 initialize() | ||
| 24 | |||
| 25 | Create a RWDE object and populate it with the project configuration content. | ||
| 26 | |||
| 27 | =cut | ||
| 28 | |||
| 29 | sub initialize { | ||
| 30 | my ($self, $params) = @_; | ||
| 31 | |||
| 32 | # where the config file lives. | ||
| 33 | |||
| 34 | if (not defined $$params{config_file}){ | ||
| 35 | throw RWDE::DevelException({ info => "Config file not specified for loading" }); | ||
| 36 | } | ||
| 37 | |||
| 38 | my %conf = %{ LoadFile($$params{config_file}) }; | ||
| 39 | |||
| 40 | $self->{_data} = $conf{Service}; | ||
| 41 | |||
| 42 | foreach my $field (keys %{ $conf{Service} }) { | ||
| 43 | $static_fields{$field} = [ 'char', 'Configuration parameter' ]; | ||
| 44 | } | ||
| 45 | |||
| 46 | %modifiable_fields = (); | ||
| 47 | |||
| 48 | %fields = (%static_fields, %modifiable_fields); | ||
| 49 | |||
| 50 | @static_fieldnames = sort keys %static_fields; | ||
| 51 | @modifiable_fieldnames = sort keys %modifiable_fields; | ||
| 52 | @fieldnames = sort keys %fields; | ||
| 53 | |||
| 54 | return (); | ||
| 55 | } | ||
| 56 | |||
| 57 | 1; |