Class: OroGen::Gen::RTT_CPP::Project

Inherits:
Object
  • Object
show all
Includes:
OpaqueHandling
Defined in:
lib/orogen/gen/project.rb

Overview

This is the root class for all oroGen features: one Project instance represents one oroGen project specification.

Toplevel statements in the .orogen files are instance methods on a Project instance. For instance, the

task_context "Name" do
   ...
end

call is actually a call to #task_context.

An existing orogen file can be loaded with Project.load

Direct Known Subclasses

ImportedProject

Defined Under Namespace

Classes: MissingTaskLibrary, TypeImportError

Constant Summary collapse

CMAKE_GENERATED_CONFIG =
%w{Base.cmake TaskLib.cmake}
@@standard_tasks =
nil

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from OpaqueHandling

#find_opaque_for_intermediate, #intermediate_type?, #intermediate_type_for, #intermediate_type_name_for, #m_type?, #opaque_specification

Constructor Details

#initializeProject

Returns a new instance of Project



249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/orogen/gen/project.rb', line 249

def initialize
    @tasks = Hash.new
    Project.standard_tasks.each do |t|
        @tasks[t.name] = t
    end
    @orogen_project = true
    @self_tasks = []
    @known_typekits = Hash.new
    @known_projects = Hash.new

    @name    = nil
    @version = "0.0"
    @used_typekits  = []
    @used_libraries = []
    @typekit_libraries = []
    @used_task_libraries = Set.new
    @typekit = nil

    @deployers = []

    @loaded_orogen_projects = Hash.new
    @loaded_typekits = Hash.new
    @enabled_transports = Set.new
    @opaques = Array.new
    @loaded_deployments = Hash.new

    # Load orocos-specific types which cannot be used in the
    # project-defined typekit but can be used literally in argument
    # lists or property types
    @registry = Typelib::Registry.new
    @opaque_registry = Typelib::Registry.new
    Typelib::Registry.add_standard_cxx_types(registry)
    Project.using_rtt_typekit(self)

    @max_sizes = Hash.new { |h, k| h[k] = Hash.new }
    @disabled_namespaces = ['test']
end

Instance Attribute Details

#deffileObject

The definition file: the full path to the .orogen file which has been loaded to define this object

nil if no file has been used



158
159
160
# File 'lib/orogen/gen/project.rb', line 158

def deffile
  @deffile
end

#define_default_deployments=(value) ⇒ Object (writeonly)

Sets the attribute define_default_deployments

Parameters:

  • value

    the value to set the attribute define_default_deployments to.



984
985
986
# File 'lib/orogen/gen/project.rb', line 984

def define_default_deployments=(value)
  @define_default_deployments = value
end

#deployersObject (readonly)

The deployment modes that are required for this generation



444
445
446
# File 'lib/orogen/gen/project.rb', line 444

def deployers
  @deployers
end

#disabled_namespacesObject (readonly)

returns all the disabled namespaces



106
107
108
# File 'lib/orogen/gen/project.rb', line 106

def disabled_namespaces
  @disabled_namespaces
end

#enabled_transportsObject (readonly)

The set of transport names that are enabled in this project



1382
1383
1384
# File 'lib/orogen/gen/project.rb', line 1382

def enabled_transports
  @enabled_transports
end

#extended_states=(value) ⇒ Object (writeonly)

Sets the attribute extended_states

Parameters:

  • value

    the value to set the attribute extended_states to.



976
977
978
# File 'lib/orogen/gen/project.rb', line 976

def extended_states=(value)
  @extended_states = value
end

#loaded_deploymentsObject (readonly)

The set of deployments known so far, as a mapping from the deployment name to the Spec::Deployment instance that describes it



247
248
249
# File 'lib/orogen/gen/project.rb', line 247

def loaded_deployments
  @loaded_deployments
end

#loaded_orogen_projectsObject (readonly)

The set of task libraries that are already loaded on this oroGen project



329
330
331
# File 'lib/orogen/gen/project.rb', line 329

def loaded_orogen_projects
  @loaded_orogen_projects
end

#loaded_typekitsObject (readonly)

The set of typekits that are already loaded on this oroGen project



325
326
327
# File 'lib/orogen/gen/project.rb', line 325

def loaded_typekits
  @loaded_typekits
end

#opaque_registryObject (readonly)

The Typelib::Registry object with only opaque definitions. This does include the opaques defined in our own typekit



452
453
454
# File 'lib/orogen/gen/project.rb', line 452

def opaque_registry
  @opaque_registry
end

#opaquesObject (readonly)

Returns the value of attribute opaques



516
517
518
# File 'lib/orogen/gen/project.rb', line 516

def opaques
  @opaques
end

#registryObject (readonly)

The Typelib::Registry object holding all known types defined in this project



98
99
100
# File 'lib/orogen/gen/project.rb', line 98

def registry
  @registry
end

#self_tasksObject (readonly)

A set of TaskContext instances listing the tasks defined in this project.

See #tasks for the set of all task definitions available in the project.



94
95
96
# File 'lib/orogen/gen/project.rb', line 94

def self_tasks
  @self_tasks
end

#tasksObject (readonly)

A set of TaskContext instances listing all the tasks whose definition is available in this project. This includes the task definitions imported from other task libraries.

See #self_tasks for the set of tasks defined in this project.



87
88
89
# File 'lib/orogen/gen/project.rb', line 87

def tasks
  @tasks
end

#typekit_librariesObject (readonly)

The set of pkg-config dependencies we depend on



147
148
149
# File 'lib/orogen/gen/project.rb', line 147

def typekit_libraries
  @typekit_libraries
end

#used_librariesObject (readonly)

The set of pkg-config dependencies we depend on



145
146
147
# File 'lib/orogen/gen/project.rb', line 145

def used_libraries
  @used_libraries
end

#used_task_librariesObject (readonly)

A set of ImportedProject objects describing libraries which define tasks. They have to provide a .orogen file which lists the tasks and their properties.



152
153
154
# File 'lib/orogen/gen/project.rb', line 152

def used_task_libraries
  @used_task_libraries
end

#used_typekitsObject (readonly)

The set of typekits that are to be used in this project. This is a set of ImportedTypekit instances.



448
449
450
# File 'lib/orogen/gen/project.rb', line 448

def used_typekits
  @used_typekits
end

Class Method Details

.load(file, verbose = true) ⇒ Object

Create a new Project object by loading the given orogen specification file



184
185
186
187
188
# File 'lib/orogen/gen/project.rb', line 184

def self.load(file, verbose = true)
    project = new
    project.load(file, verbose)
    project
end

.standard_tasksObject

The set of standard project defined by RTT and OCL. They are defined as orogen-specification in the rtt.orogen and ocl.orogen, present in orogen source code.



221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/orogen/gen/project.rb', line 221

def self.standard_tasks
    if @@standard_tasks
        @@standard_tasks
    else
        @@standard_tasks = []
        OroGen::Loaders::RTT.standard_projects.each do |project|
            def project.orogen_project?; false end
            @@standard_tasks.concat project.tasks.values
        end
    end

    @@standard_tasks
end

.using_rtt_typekit(obj) ⇒ Object



287
288
289
290
291
292
293
294
# File 'lib/orogen/gen/project.rb', line 287

def self.using_rtt_typekit(obj)
    OroGen::Loaders::RTT.standard_typekits.each do |tk|
        if tk.name == 'orocos'
            tk.extend RTTTypekit
        end
        obj.using_typekit(tk)
    end
end

Instance Method Details

#additional_plugin_source_dirsObject

Returns all subdirectores that task-extens want to add This is used within the CMake-list generation to add custom targets to the build process



311
312
313
314
315
316
317
318
319
320
321
322
# File 'lib/orogen/gen/project.rb', line 311

def additional_plugin_source_dirs
    dirs = []
    tasks.each do |name,task|
        task.extensions.each do |ext|
            next if !ext.respond_to? "each_auto_gen_source_directory"
            ext.each_auto_gen_source_directory do |elem|
                dirs << elem
            end
        end
    end
    dirs.uniq
end

#base_dirObject

If set, the directory in which the .orogen file is. This is used to update include paths for instance.



176
177
178
179
180
# File 'lib/orogen/gen/project.rb', line 176

def base_dir
    if deffile
        File.dirname(deffile)
    end
end

#default_task_superclassObject

Returns the TaskContext object for the default task contexts superclass (i.e. RTT::TaskContext)



298
299
300
# File 'lib/orogen/gen/project.rb', line 298

def default_task_superclass
    Project.standard_tasks.find { |t| t.name == "RTT::TaskContext" }
end

#define_default_deployments?Boolean

Returns:

  • (Boolean)


986
987
988
989
990
# File 'lib/orogen/gen/project.rb', line 986

def define_default_deployments?
    if @define_default_deployments.nil? then Generation.define_default_deployments_enabled?
    else @define_default_deployments
    end
end

#define_dummy_types=(value) ⇒ Object

If true, #find_type will create a new Null type when unknown types are found. This is used to use orogen specifications before writing down the projects.



103
# File 'lib/orogen/gen/project.rb', line 103

attr_predicate :define_dummy_types?, true

#define_dummy_types?Boolean

If true, #find_type will create a new Null type when unknown types are found. This is used to use orogen specifications before writing down the projects.

Returns:

  • (Boolean)


103
# File 'lib/orogen/gen/project.rb', line 103

attr_predicate :define_dummy_types?, true

#deployment(name, &block) ⇒ Object

call-seq:

deployment(name[, options]) do
    specification
end

Defines a deployment, i.e. an Unix executable in which a certain number of TaskContext are instanciated, associated with threads and triggers and (optionally) connected to each other and/or started.

The statements in the given block are method calls to a StaticDeployment instance, so see the documentation of that class for more information.



1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
# File 'lib/orogen/gen/project.rb', line 1273

def deployment(name, &block) # :yield:
    # If we have a typekit, resolve all pending loads
    if typekit
        typekit.perform_pending_loads
    end

    if has_deployment?(name)
        raise ArgumentError, "there is already a deployment named '#{name}' in this oroGen project"
    end

    deployer = RTT_CPP::Deployment.new(self, name, &block)
    @enabled_transports.each do |t|
        deployer.enable_transport(t)
    end
    deployer.instance_eval(&block) if block_given?

    # If the deployer is meant to be installed, check that there is
    # not alreay a deployment with that name
    # if deployer.install?
    #     begin
    #         pkg = Utilrb::PkgConfig.new("orogen-#{name}")
    #         if pkg.project_name != project.name
    #             raise ArgumentError, "#{name} is a deployment already used in #{pkg.project_name}"
    #         end
    #     rescue Utilrb::PkgConfig::NotFound
    #     end
    # end

    @deployers << deployer
    deployer
end

#disable_namespace(value) ⇒ Object



125
# File 'lib/orogen/gen/project.rb', line 125

def disable_namespace(value); @disabled_namespaces << value end

#enable_extension(extensions) ⇒ Object

Enable the given transports



1398
1399
1400
1401
1402
# File 'lib/orogen/gen/project.rb', line 1398

def enable_extension(extensions)
    extensions.each do |ext|
        Spec::TaskContext.default_extensions << ext
    end
end

#enable_namespace(value) ⇒ Object



124
# File 'lib/orogen/gen/project.rb', line 124

def enable_namespace(value); @disabled_namespaces.delete(value) end

#enable_transports(*transport_names) ⇒ Object

Enable the given transports



1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
# File 'lib/orogen/gen/project.rb', line 1385

def enable_transports(*transport_names)
    transport_names.each do |name|
        if typekit
            typekit.enable_plugin(name)
        end
        deployers.each do |d|
            d.enable_transport(name)
        end
    end
    @enabled_transports |= transport_names.to_set
end

#eval(name, file_contents, verbose = true) ⇒ Object



1375
1376
1377
1378
1379
# File 'lib/orogen/gen/project.rb', line 1375

def eval(name, file_contents, verbose = true)
    self.deffile = "#{name}.orogen"
    Kernel.eval_dsl_file_content(deffile, file_contents, self, [OroGen, RTT_CPP], verbose)
    self
end

#export_types(*args) ⇒ Object

Explicitely selects types that should be added to the RTT type system.

EXPERIMENTAL

See Typekit#export_types



969
970
971
972
973
974
# File 'lib/orogen/gen/project.rb', line 969

def export_types(*args)
    if !typekit(false)
        raise ConfigError, "using export_types here makes no sense since no new types are defined in this project"
    end
    typekit(false).export_types(*args)
end

#exported_type?(typename) ⇒ Boolean

Returns true if typename can be used on a task context interface

Returns:

  • (Boolean)


539
540
541
542
543
# File 'lib/orogen/gen/project.rb', line 539

def exported_type?(typename)
    imported_typekits_for(typename).any? do |tk|
        tk.interface_type?(typename)
    end
end

#extended_state_support?Boolean

Returns:

  • (Boolean)


620
621
622
# File 'lib/orogen/gen/project.rb', line 620

def extended_state_support?
    self_tasks.any? { |t| t.extended_state_support? }
end

#extended_states?Boolean

Returns:

  • (Boolean)


978
979
980
981
982
# File 'lib/orogen/gen/project.rb', line 978

def extended_states?
    if @extended_states.nil? then Generation.extended_states_enabled?
    else @extended_states
    end
end

#external_task_context(name, **options, &block) ⇒ Object

Declares a task context that is being imported, not defined



1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
# File 'lib/orogen/gen/project.rb', line 1046

def external_task_context(name, **options, &block)
    if has_task_context?(name)
        raise ArgumentError, "there is already a #{name} task"
    elsif has_namespace?(name)
        raise ArgumentError, "there is already a namespace called #{name}, this is not supported by orogen"
    end

    klass = options.fetch(:class, Spec::TaskContext)
    new_task = klass.new(self, "#{self.name}::#{name}", **options)
    Spec.load_documentation(new_task, /^task_context/)
    new_task.instance_eval(&block) if block_given?
    tasks[new_task.name] = new_task
    self_tasks << new_task
    new_task
end

#find_deployment_by_name(name) ⇒ Spec::Deployment?

Returns the deployment model with the given name

Returns:

  • (Spec::Deployment, nil)

    the model found, or nil if none is registered with that name



1309
1310
1311
# File 'lib/orogen/gen/project.rb', line 1309

def find_deployment_by_name(name)
    deployers.find { |obj| obj.name == name }
end

#find_interface_type(typename) ⇒ Object

Returns the type object for typename, validating that we can use it in a task interface, i.e. that it will be registered in the RTT's typeinfo system



548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
# File 'lib/orogen/gen/project.rb', line 548

def find_interface_type(typename)
    type = find_type(typename)
    if type < Typelib::NullType && define_dummy_types?
        return type
    end

    if type < Typelib::ArrayType
        raise ConfigError, "static arrays are not valid interface types. Use an array in a structure or a std::vector"
    end

    typekits   = imported_typekits_for(type.name)
    if !typekits.empty?
        OroGen.debug { "#{type.name} is exported by #{typekits.map(&:name).join(", ")}" }
    end

    if !typekits.empty? && !typekits.any? { |tk| tk.interface_type?(type.name) }
        raise ConfigError, "#{type.name}, defined in the #{typekits.map(&:name).join(", ")} typekits, is never exported"
    end
    type
end

#find_task_context(obj) ⇒ Object

Find the TaskContext object described by obj. obj can either be a TaskContext instance, in which case it is returned, or a task context name, in which case the corresponding TaskContext object is searched in the set of known ones (i.e. the ones defined in this project or in the task libraries loaded by #using_task_library).

Raises ArgumentError if no such task context exists

If the task context is defined in this project, the leading namespace can be omitted. For example, in a project defined by

name 'myProject'
task_context 'TC' do
end

the following two statements are equivalent

find_task_context('TC')
find_task_context('myProject::TC')

This is not true for imported task contexts. For instance, for

name 'otherProject'
using_task_library 'myProject'

the following statement will return nil:

find_task_context('TC')

while this one works as expected:

find_task_context('myProject::TC')


402
403
404
405
406
407
408
409
410
411
412
413
414
415
# File 'lib/orogen/gen/project.rb', line 402

def find_task_context(obj)
    task_model =
        if obj.respond_to?(:to_str)
            klass = tasks[obj.to_str]
            klass || tasks["#{name}::#{obj}"]
        else
            obj
        end

    if !task_model
        raise ArgumentError, "cannot find a task context model named #{obj}"
    end
    task_model
end

#find_type(typename, is_normalized = false) ⇒ Object

Find the Typelib::Type object for name. name can be either a Typelib::Type object directly, or a type name. In both cases, the type must have been defined either by the project's own typekit or by the ones imported by #using_typekit



577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
# File 'lib/orogen/gen/project.rb', line 577

def find_type(typename, is_normalized = false)
    if typename
        if typename.kind_of?(Class) && typename <= Typelib::Type
            type = typename
            typename = type.name
            is_normalized = true
        end

        if typename.respond_to?(:to_str)
            typename = typename.gsub('::', '/')
            if !is_normalized
                typename = Typelib::Type.normalize_typename(typename)
            end
            found_type = begin
                             registry.build(typename)
                         rescue Typelib::NotFound
                             # We may need to define this type for ourselves, so
                             # make the typekit define it ...
                             typekit(true).find_type(typename)
                             # ... and return our own version of it, not the
                             # typekit's one
                             registry.build(typename)
                         end

            if type && found_type != type
                raise ArgumentError, "type definition mismatch between #{type} and #{found_type}"
            end
            return found_type
        else
            raise ArgumentError, "expected a type name or a type object, got #{typename}"
        end
    end

rescue Typelib::NotFound => e
    if define_dummy_types?
        return registry.create_null(typename)
    elsif typekit && typekit.respond_to?(:pending_loads) && !typekit.pending_loads.empty?
        typekit.perform_pending_loads
        retry
    end
    raise e.class, e.message, e.backtrace
end

#find_typekit(typekit_name) ⇒ Object

Returns the typekit object that corresponds to typekit_name, or nil if there is none



304
305
306
# File 'lib/orogen/gen/project.rb', line 304

def find_typekit(typekit_name)
    project.used_typekits.find { |tk| tk.name == typekit_name }
end

#generateObject

Generate the project's source files



625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
# File 'lib/orogen/gen/project.rb', line 625

def generate
    unless name
        raise ArgumentError, "you must set a name for this project"
    end

    if name !~ /^[a-z][a-z0-9\_]+$/
        raise ConfigError, "invalid name '#{name}': names must be all lowercase, can contain alphanumeric characters and underscores and start with a letter"
    end
    if !deffile
        raise ArgumentError, "there is no orogen file for this project, cannot generate"
    end

    # For consistency in templates
    project = self

    # First, generate a to-be-installed version of the orogen file.
    # We do that to add command-line options like corba
    # enable/disable and extended state support.
    if File.file?(deffile)
        orogen_file = RTT_CPP.render_template "project.orogen", binding
        orogen_file = RTT_CPP.save_automatic(File.basename(deffile), orogen_file)
        # In any case, touch the target file for the sake of
        # the check-uptodate targets
        FileUtils.touch(orogen_file)
    else
        dir = AUTOMATIC_AREA_NAME
        FileUtils.mkdir_p dir
        FileUtils.touch(File.join(dir, File.basename(deffile)))
    end

    # The typekit and the task libraries populate a fake
    # installation directory .orogen/<project_name> so that the
    # includes can be referred to as <project_name>/taskNameBase.hpp.
    #
    # We have first to remove the way orogen was doing it before,
    # and then let typekit and task library do what they have to do
    fake_install_dir = File.join(project.base_dir, AUTOMATIC_AREA_NAME, project.name)
    if File.symlink?(fake_install_dir)
        FileUtils.rm_f fake_install_dir
        Dir.glob(File.join(project.base_dir, AUTOMATIC_AREA_NAME, "tasks", "*")).each do |path|
            FileUtils.rm_f path if File.symlink?(path)
        end
    end

    # This piece of code is a header-only definition that is generic
    # and should be usable in any orogen project
    #
    # (I know, this is ugly)
    # typelib_marshaller = Generation.render_template "typekit/TypelibMarshaller.hpp", binding
    # Generation.save_automatic("typekit/TypelibMarshaller.hpp", typelib_marshaller)
    # typelib_marshaller = Generation.render_template "typekit/TypelibMarshallerBase.hpp", binding
    # Generation.save_automatic("TypelibMarshallerBase.hpp", typelib_marshaller)
    # typelib_marshaller = Generation.render_template "typekit/TypelibMarshallerBase.cpp", binding
    # Generation.save_automatic("typekit/TypelibMarshallerBase.cpp", typelib_marshaller)

    # Generate the state enumeration types for each of the task
    # contexts, and load it
    if self_tasks.any?(&:extended_state_support?)
        state_types = Generation.render_template(
            "tasks", "TaskStates.hpp", binding)
        header = Generation.save_automatic(
            'typekit', 'types', project.name, "TaskStates.hpp", state_types)
        typekit(true).load(header)
    end

    if typekit
        typekit.generate
    end
    validate_max_sizes_spec

    pc = Generation.render_template "project.pc", binding
    Generation.save_automatic "orogen-project-#{name}.pc.in", pc

    if !self_tasks.empty?
        self_tasks.each { |t| t.generate }

        deployer = Generation.render_template "tasks", "DeployerComponent.cpp", binding
        Generation.save_automatic "tasks", "DeployerComponent.cpp", deployer
        pc = Generation.render_template "tasks", "tasks.pc", binding
        Generation.save_automatic "tasks", "#{name}-tasks.pc.in", pc
    end

    ignorefile = Generation.render_template "gitignore", binding
    Generation.save_user ".gitignore", ignorefile

    doxygen = Generation.render_template "Doxyfile.in", binding
    Generation.save_user "Doxyfile.in", doxygen

    if !deployers.empty?
        deployers.each { |t| t.generate }
    end

    generate_build_system
    Generation.cleanup_dir(Generation::AUTOMATIC_AREA_NAME)
    self
end

#generate_build_systemObject

Generate the CMake build system for this project



725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
# File 'lib/orogen/gen/project.rb', line 725

def generate_build_system # :nodoc:
    project = self

    FileUtils.mkdir_p File.join(Generation::AUTOMATIC_AREA_NAME, 'config')
    target_dir = Generation::AUTOMATIC_AREA_NAME
    Dir.glob File.join(Generation.template_path('config'), '*') do |path|
        basename    = File.basename(path)
        if !CMAKE_GENERATED_CONFIG.include?(basename)
            Generation.save_automatic 'config', basename, File.read(path)
        end
    end

    # Generate the automatic part of the root cmake configuration
    CMAKE_GENERATED_CONFIG.each do |file|
        cmake = Generation.render_template "config", file, binding
        Generation.save_automatic "config", "#{name}#{file}", cmake
    end

    if !self_tasks.empty?
        cmake = Generation.render_template 'tasks', 'CMakeLists.txt', binding
        Generation.save_user('tasks', "CMakeLists.txt", cmake)
    end

    cmake = Generation.render_template 'CMakeLists.txt', binding
    Generation.save_user("CMakeLists.txt", cmake)
end

#has_deployment?(name) ⇒ Boolean

True if there is a deployment with the given name in this oroGen project

Returns:

  • (Boolean)


1256
1257
1258
# File 'lib/orogen/gen/project.rb', line 1256

def has_deployment?(name)
    deployers.any? { |d| d.name == name }
end

#has_library?(name) ⇒ Boolean

Returns true if the following pkg-config package is available on this system

Returns:

  • (Boolean)


827
828
829
830
831
832
# File 'lib/orogen/gen/project.rb', line 827

def has_library?(name)
    Utilrb::PkgConfig.new(name)
    true
rescue Utilrb::PkgConfig::NotFound => e
    false
end

#has_namespace?(name) ⇒ Boolean

Returns true if there is, in the type registry, a namespace with the given name.

Returns:

  • (Boolean)


429
430
431
432
433
434
435
436
437
438
439
440
441
# File 'lib/orogen/gen/project.rb', line 429

def has_namespace?(name)
    if name[0] != '/'
        name = '/' + name
    end
    if name[-1] != '/'
        name << '/'
    end

    registry.each(name, :with_aliases => true) do |*_|
        return true
    end
    return false
end

#has_task_context?(name) ⇒ Boolean

Returns true if there is a registered task context with the given name, and false otherwise

Returns:

  • (Boolean)


423
424
425
# File 'lib/orogen/gen/project.rb', line 423

def has_task_context?(name)
    tasks.has_key?(name.to_str) || tasks.has_key?("#{self.name}::#{name}")
end

#has_task_library?(name) ⇒ Boolean

Returns true if name is a valid task library on this system

This can be used to make the definition of parts of the oroGen project conditional

Returns:

  • (Boolean)


1177
1178
1179
1180
1181
1182
# File 'lib/orogen/gen/project.rb', line 1177

def has_task_library?(name)
    orogen_project_description(name)
    true
rescue MissingTaskLibrary
    false
end

#has_typekit?(name) ⇒ Boolean

Returns true if name is a known typekit on this system

This can be used to make the definition of parts of the oroGen project conditional

Returns:

  • (Boolean)


1166
1167
1168
1169
1170
1171
# File 'lib/orogen/gen/project.rb', line 1166

def has_typekit?(name)
    orogen_typekit_description(name)
    true
rescue ConfigError
    false
end

#import_typekit(name) ⇒ Object



878
879
880
881
882
883
884
885
886
887
888
889
890
# File 'lib/orogen/gen/project.rb', line 878

def import_typekit(name)
    if tk = loaded_typekits[name]
        return tk
    end

    pkg, registry_xml, typelist_txt = orogen_typekit_description(name)
    begin
        loaded_typekits[name] = ImportedTypekit.
            from_raw_data(self, name, pkg, registry_xml, typelist_txt)
    rescue Exception => e
        raise e, "failed to import typekit #{name}: #{e.message}", e.backtrace
    end
end

#import_types_from(name, *args) ⇒ Object

Imports the types defined by the given argument

name can either be another orogen project or a header file. In the first case, the current project will be reusing the type definitions and marshalling support already compiled by the other project. In the second case, it will build and install a library to support the new types.



469
470
471
472
473
474
475
476
477
# File 'lib/orogen/gen/project.rb', line 469

def import_types_from(name, *args)
    if has_typekit?(name)
        using_typekit name
    else
        typekit(true).load name, true, *args
    end
rescue LoadError
    raise TypeImportError.new(name), "cannot find typekit or file #{name}. If this is supposed to be a header, the following include path was used: #{typekit.include_dirs.to_a.join(":")}"
end

#imported?Boolean

Returns:

  • (Boolean)


241
242
243
# File 'lib/orogen/gen/project.rb', line 241

def imported?
    false
end

#imported_type?(typename) ⇒ Boolean

Returns true if typename has been defined by a typekit imported by using_typekit

Returns:

  • (Boolean)


534
535
536
# File 'lib/orogen/gen/project.rb', line 534

def imported_type?(typename)
    !imported_typekits_for(typename).empty?
end

#imported_typekits_for(typename) ⇒ Object

Returns the typekit object that defines this type



525
526
527
528
529
530
# File 'lib/orogen/gen/project.rb', line 525

def imported_typekits_for(typename)
    if typename.respond_to?(:name)
        typename = typename.name
    end
    return used_typekits.find_all { |tk| tk.includes?(typename) }
end

#inspectObject



117
# File 'lib/orogen/gen/project.rb', line 117

def inspect; to_s end

#linux?Boolean

True if the orocos target is gnulinux

Returns:

  • (Boolean)


120
# File 'lib/orogen/gen/project.rb', line 120

def linux?; orocos_target == 'gnulinux' end

#load(file, verbose = true) ⇒ Object

Apply the project description included in file to self



1369
1370
1371
1372
1373
# File 'lib/orogen/gen/project.rb', line 1369

def load(file, verbose = true)
    self.deffile = File.expand_path(file)
    Kernel.eval_dsl_file(deffile, self, [OroGen, RTT_CPP], verbose)
    self
end

#load_orogen_deployment(name) ⇒ Object

Finds the specification for the deployment name



1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
# File 'lib/orogen/gen/project.rb', line 1089

def load_orogen_deployment(name)
    if deployment = loaded_deployments[name]
        return deployment
    end

    begin
        pkg = Utilrb::PkgConfig.new("orogen-#{name}")
    rescue Utilrb::PkgConfig::NotFound
        raise ArgumentError, "there is no deployment called '#{name}'"
    end

    tasklib = load_orogen_project(pkg.project_name)
    deployment = tasklib.deployers.find { |d| d.name == name }
    if !deployment
        raise InternalError, "cannot find the deployment called #{name} in #{tasklib}. Candidates were #{tasklib.deployers.map(&:name).join(", ")}"
    end
    loaded_deployments[name] = deployment
end

#load_orogen_project(name, options = Hash.new) ⇒ Object

Loads the oroGen project name

The returned value is an instance of ImportedProject



1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
# File 'lib/orogen/gen/project.rb', line 1065

def load_orogen_project(name, options = Hash.new)
    name = name.to_str
    if lib = loaded_orogen_projects[name]
        return lib
    end
    options = Kernel.validate_options options,
        :define_dummy_types => false

    pkg, description = orogen_project_description(name)

    OroGen.info "loading oroGen project #{name} on #{self.name}"
    lib = ImportedProject.new(self, pkg)
    lib.define_dummy_types = options[:define_dummy_types]
    if File.file?(description)
        lib.load(description)
    else
        lib.eval(name, description)
    end

    register_loaded_project(lib.name, lib)
    lib
end

#load_task_library(name, options) ⇒ Object

Loads the task library name

The returned value is an instance of ImportedProject



1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
# File 'lib/orogen/gen/project.rb', line 1117

def load_task_library(name, options)
    if !options.kind_of?(Hash)
        options = { :validate => options }
    end
    options = Kernel.validate_options options,
        :validate => true, :define_dummy_types => false

    tasklib = load_orogen_project(name, :define_dummy_types => options[:define_dummy_types])
    if options[:validate] && tasklib.self_tasks.empty?
        raise ConfigError, "#{name} is an oroGen project, but it defines no task library"
    end
    tasklib
end

#load_typekit(name) ⇒ Object

Returns the ImportedTypekit object that is representing an installed typekit.



1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
# File 'lib/orogen/gen/project.rb', line 1151

def load_typekit(name)
    name = name.to_str
    if tk = loaded_typekits[name]
        return tk
    end

    pkg, registry_xml, typelist_txt = orogen_typekit_description(name)
    loaded_typekits[name] = ImportedTypekit.
        from_raw_data(self, name, pkg, registry_xml, typelist_txt)
end

#max_sizes(typename = nil, *values, &block) ⇒ Object

Adds some max size specification for a given type

See OutputPort#max_sizes for a complete description of this functionality. The sizes specified through this global method are applied on every port of the provided type



195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/orogen/gen/project.rb', line 195

def max_sizes(typename = nil, *values, &block)
    if !typename && values.empty?
        return @max_sizes
    end

    type  = find_type(typename)
    # Cannot completely validate the spec, since we may not yet have
    # the m-types. Do what we can, we'll do full blown validation
    # later
    sizes = Spec::Port.validate_max_sizes_spec(nil, values)
    @max_sizes[type.name].merge!(sizes, &block)
end

#namespace_disabled?(value) ⇒ Boolean

Returns:

  • (Boolean)


126
# File 'lib/orogen/gen/project.rb', line 126

def namespace_disabled?(value); @disabled_namespaces.include?(value) end

#orocos_targetObject

The target operating system for orocos. Uses the OROCOS_TARGET environment variable, if set, and defaults to gnulinux otherwise.



110
111
112
# File 'lib/orogen/gen/project.rb', line 110

def orocos_target
    RTT_CPP.orocos_target.dup
end

#orogen_projectObject

:method:orogen_project?

True if this class represents an oroGen project, false otherwise



239
# File 'lib/orogen/gen/project.rb', line 239

attr_predicate :orogen_project, true

#orogen_project=(value) ⇒ Object

:method:orogen_project?

True if this class represents an oroGen project, false otherwise



239
# File 'lib/orogen/gen/project.rb', line 239

attr_predicate :orogen_project, true

#orogen_project?Boolean

:method:orogen_project?

True if this class represents an oroGen project, false otherwise

Returns:

  • (Boolean)


239
# File 'lib/orogen/gen/project.rb', line 239

attr_predicate :orogen_project, true

#orogen_project_description(name) ⇒ Object

call-seq:

orogen_project_description(name) => pkg, description

Returns the orogen description for the oroGen project name.

In the return value, pkg is the PkgConfig object that describes the project, and can be nil. description is either the path to the oroGen description file, or its content.



347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
# File 'lib/orogen/gen/project.rb', line 347

def orogen_project_description(name)
    if description = @known_projects[name]
        return description
    end

    pkg = begin
              begin
                  Utilrb::PkgConfig.new "orogen-project-#{name}"
              rescue Utilrb::PkgConfig::NotFound
                  Utilrb::PkgConfig.new "#{name}-tasks-#{orocos_target}"
              end

          rescue Utilrb::PkgConfig::NotFound
              raise MissingTaskLibrary.new(name), "no task library named '#{name}' is available"
          end

    @known_projects[name] = [pkg, pkg.deffile]
end

#orogen_typekit_description(name) ⇒ Object

Returns the description information for the given typekit



1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
# File 'lib/orogen/gen/project.rb', line 1132

def orogen_typekit_description(name)
    if description = @known_typekits[name]
        return description
    end

    pkg = begin
              Utilrb::PkgConfig.new("#{name}-typekit-#{orocos_target}")
          rescue Utilrb::PkgConfig::NotFound => e
              raise ConfigError, "no typekit named '#{name}' is available (could not load pkg-config info #{name}-typekit-#{orocos_target} in #{ENV['PKG_CONFIG_PATH']})"
          end

    registry = File.read(pkg.type_registry)
    typelist = File.join(File.dirname(pkg.type_registry), "#{name}.typelist")
    typelist = File.read(typelist)
    @known_typekits[name] = [pkg, registry, typelist]
end

#pretty_print(pp) ⇒ Object

Displays the content of this oroGen project in a nice form



1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
# File 'lib/orogen/gen/project.rb', line 1345

def pretty_print(pp) # :nodoc:
    if !self_tasks.empty?
        pp.text "  Task Contexts:"
        pp.nest(4) do
            pp.breakable
            pp.seplist(self_tasks) do |t|
                t.pretty_print(pp)
            end
        end
    end

    if !deployers.empty?
        pp.breakable if !self_tasks.empty?
        pp.text "  Deployers:"
        pp.nest(4) do
            pp.breakable
            pp.seplist(deployers) do |d|
                d.pretty_print(pp)
            end
        end
    end
end

#projectObject

This is for the sake of DSL handling



1342
# File 'lib/orogen/gen/project.rb', line 1342

def project; self end

#register_loaded_project(name, obj) ⇒ Object

Called to store a loaded project for reuse later



1109
1110
1111
1112
# File 'lib/orogen/gen/project.rb', line 1109

def register_loaded_project(name, obj)
    OroGen.info "registering oroGen project #{name}" 
    loaded_orogen_projects[name] = obj
end

#register_orogen_file(path, name = nil) ⇒ Object

Registers an orogen file so that it can be loaded later using_task_library and friends. The project name is assumed to be the file basename



369
370
371
372
# File 'lib/orogen/gen/project.rb', line 369

def register_orogen_file(path, name = nil)
    name ||= File.basename(path, ".orogen")
    @known_projects[name] = [nil, path]
end

#register_typekit(name, registry_xml, typelist) ⇒ Object



892
893
894
# File 'lib/orogen/gen/project.rb', line 892

def register_typekit(name, registry_xml, typelist)
    @known_typekits[name] = [nil, registry_xml, typelist]
end

#resolve_type(typename) ⇒ Object



569
570
571
# File 'lib/orogen/gen/project.rb', line 569

def resolve_type(typename)
    find_type(typename)
end

#rtt_registryObject

A Typelib::Registry object defining all the types that are defined in the RTT, as for instance vector<double> and string.



522
# File 'lib/orogen/gen/project.rb', line 522

def rtt_registry; Project.rtt_registry end

#simple_deployment(name, klass) ⇒ Object

call-seq:

simple_deployment(name, klass) => task_context

Create a deployment called name with one task of type klass also called name.

The returned value allows to set up the task. For instance, to deploy a periodic task one would do

simple_deployment("task", "Task").
    periodic(0.001)


1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
# File 'lib/orogen/gen/project.rb', line 1324

def simple_deployment(name, klass)
    if has_task_library?('logger')
        using_task_library "logger"
    end

    project = self.project

    result = nil
    deployment name do
        result = task name, klass
        if project.has_task_library?('logger')
            add_default_logger
        end
    end
    result
end

#static_deployment(&block) ⇒ Object

DEPRECATED. Use #deployment instead



1246
1247
1248
1249
1250
1251
1252
# File 'lib/orogen/gen/project.rb', line 1246

def static_deployment(&block)
    OroGen::Gen::RTT_CPP.warn "static_deployment is deprecated, use #deployment(name) instead"
    OroGen::Gen::RTT_CPP.warn "static_deployment now generates a deployment called test_#{name} that is *not* part of the installation"
    deployment = deployment("test_#{name}", &block)
    deployment.do_not_install
    deployment
end

#task_context(name, **options, &block) ⇒ Object

Creates a new task context class of this name. The generated class is defined in the project's namespace. Therefore

name "test_project"
task_context "SpecificTask" do
  .. task context specification ..
end

defines a test_project::SpecificTask class.

Task contexts are represented as instances of TaskContext. See the documentation of that class for more details.



1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
# File 'lib/orogen/gen/project.rb', line 1004

def task_context(name, **options, &block)
    if namespace_disabled?(name.split("::")[0..-2].join("::"))
        return nil
    end

    if name == self.name
        raise ArgumentError, "a task cannot have the same name as the project"
    elsif name !~ /^(\w+::)*\w+$/
        raise ArgumentError, "task names need to be valid C++ identifiers, i.e. contain only alphanumeric characters and _ (got #{name})"
    end

    name = OroGen.verify_valid_identifier(name)

    # If we have a typekit, resolve all pending loads
    if typekit
        typekit.perform_pending_loads
    end


    task = external_task_context(name, **options) do
        Spec::TaskContext.apply_default_extensions(self)
        if block_given?
            instance_eval(&block)
        end
    end
    if extended_states?
        task.extended_state_support
    end

    if !task.abstract?
        if define_default_deployments? && enabled_transports.include?('corba')
            simple_deployment(Generation.default_deployment_name(task.name), task.name)
        end
    end

    task
end

#task_model_from_name(name) ⇒ Object



417
418
419
# File 'lib/orogen/gen/project.rb', line 417

def task_model_from_name(name)
    find_task_context(name)
end

#tasklib_dependenciesObject

Returns a list of BuildDependency object that represent the dependencies for the task library



763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
# File 'lib/orogen/gen/project.rb', line 763

def tasklib_dependencies
    # Get the set of typekits that we directly depend on, because
    # some of our task classes use their types in their interface.
    used_typekits = self_tasks.inject(Set.new) do |set, task|
        set | task.used_typekits.find_all { |tk| !tk.virtual? }.map(&:name)
    end

    used_libraries = self.used_libraries.map(&:name)
    used_tasklibs = tasklib_used_task_libraries.map(&:name)

    # Cover the package names into BuildDependency objects,
    # first for the direct dependencies. Then, we look into the
    # indirect dependencies in type_includes, remove duplicates
    # and finish
    used_typekits.map! do |name|
        build_dep = BuildDependency.new("#{name}_TYPEKIT", "#{name}-typekit-#{orocos_target}")
        build_dep.in_context('core', 'include')
        build_dep.in_context('core', 'link')
    end
    used_libraries.map! do |name|
        build_dep = BuildDependency.new(name, name)
        build_dep.in_context('core', 'include')
        build_dep.in_context('core', 'link')
    end
    used_tasklibs.map! do |name|
        build_dep = BuildDependency.new(
            "#{name}_TASKLIB",
            "#{name}-tasks-#{orocos_target}")
        build_dep.in_context('core', 'include')
        build_dep.in_context('core', 'link')
    end
    result = (used_typekits + used_libraries + used_tasklibs)

    var_names = result.map(&:var_name).to_set
    if typekit
        typekit.dependencies.each do |dep|
            next if !dep.in_context?('core') || var_names.include?(dep.var_name)
            dep = dep.dup
            dep.remove_context('link')
            result << dep
        end
    end

    result.to_set.to_a.sort_by { |dep| dep.var_name }
end

#tasklib_used_task_librariesObject

Computes the set of task libraries that our own task library depends on



754
755
756
757
758
759
# File 'lib/orogen/gen/project.rb', line 754

def tasklib_used_task_libraries
    result = self_tasks.inject(Set.new) do |set, task|
        set | task.used_task_libraries
    end
    result.to_a.sort_by(&:name)
end

#to_sObject



114
115
116
# File 'lib/orogen/gen/project.rb', line 114

def to_s
    "#<#{self.class.name}: #{name}>"
end

#type_export_policy(*args) ⇒ Object

Sets or reads the typekit's type export policy.

EXPERIMENTAL

See Typekit#type_export_policy



956
957
958
959
960
961
# File 'lib/orogen/gen/project.rb', line 956

def type_export_policy(*args)
    if !typekit(false)
        raise ConfigError, "using type_export_policy here makes no sense since no new types are defined in this project"
    end
    typekit(false).type_export_policy(*args)
end

#typekit(create = nil, &block) ⇒ Object

call-seq:

project.typekit do
   ... typekit setup ...
end => typekit
project.typekit => current typekit or nil

The first form associates a type typekit for project, as a Typekit intance. The given block can set up this Typekit instance by calling any instance method defined on it.

The second form returns a Typekit object if one is defined, and nil otherwise.



908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
# File 'lib/orogen/gen/project.rb', line 908

def typekit(create = nil, &block)
    if create.nil?
        create = true if block_given?
    end
    if create && !@typekit
        @typekit = Typekit.new(self)

        typekit.name     = name
        typekit.version  = version
        typekit.base_dir = base_dir
        typekit.type_export_policy RTT_CPP.default_type_export_policy
        if base_dir
            typekit.user_dir      = File.join(base_dir, 'typekit')
            typekit.templates_dir = File.join(base_dir, 'templates', 'typekit')
            typekit.automatic_dir = File.join(base_dir, AUTOMATIC_AREA_NAME, 'typekit')
        end

        @enabled_transports.each do |t|
            typekit.enable_plugin(t)
        end

        typekit.include_dirs |=
            used_task_libraries.map { |pkg| pkg.include_dirs }.
            flatten.to_set

        typekit_libraries.each do |tk, do_link|
            typekit.using_library(tk, :link => do_link)
        end

        # Initialize the typekit's imported_types registry
        used_typekits.each do |tk|
            typekit.using_typekit(tk)
        end
    end

    if !block_given?
        return @typekit
    else
        @typekit.instance_eval(&block)
        nil
    end
end

#using_library(name, options = Hash.new) ⇒ Object

call-seq:

using_library 'name' => self

Make the project build-depend on the pkg-config package name. This is done through the use of the pkg-config tool, so you need the external dependencies of your project to provide the necessary files (and those files to be in a directory listed in the PKG_CONFIG_PATH environment variable).

This library will be linked to both the project's typekit (if any) and its task library. This is so because the library may contain the implementation part of types that are exported by the typekit.

To reduce the link interface, you may use the :typekit option to avoid linking the library to the typekit:

using_library 'name', :typekit => false


852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
# File 'lib/orogen/gen/project.rb', line 852

def using_library(name, options = Hash.new)
    options = Kernel.validate_options options, :typekit => true, :typekit_link => nil
    pkg = Utilrb::PkgConfig.new(name)
    used_libraries << pkg

    if options[:typekit_link].nil?
        options[:typekit_link] = options[:typekit]
    end

    do_typekit = options[:typekit] || options[:typekit_link]
    if do_typekit
        typekit_libraries << [pkg, options[:typekit_link]]
    end

    if self.typekit && do_typekit
        self.typekit.using_library(pkg, :link => options[:typekit_link])
    end
    self
rescue Utilrb::PkgConfig::NotFound => e
    if e.name == name 
        raise ConfigError, "no library named '#{name}' available", e.backtrace
    else
        raise ConfigError, "a dependency of library '#{name}' is not available: library '#{e.name}' could not be found", e.backtrace
    end
end

#using_plugin(name) ⇒ Object



479
480
481
# File 'lib/orogen/gen/project.rb', line 479

def using_plugin(name)
    OroGen.load_orogen_plugin(name)
end

#using_project(name) ⇒ Object



1184
1185
1186
# File 'lib/orogen/gen/project.rb', line 1184

def using_project(name)
    using_task_library(name, false)
end

#using_task_library(name, options = Hash.new) ⇒ Object

Declares that this project depends on task contexts defined by the given orogen-generated project. After this call, the definitions of the tasks in the task library are available as 'name::task_context_name'

As for #using_library, the project is searched by name by the pkg-config tool. It means that, if PREFIX is the installation prefix where the project is installed, then

PREFIX/lib/pkgconfig

must be listed in the PKG_CONFIG_PATH environment variable.



1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
# File 'lib/orogen/gen/project.rb', line 1200

def using_task_library(name, options = Hash.new)
    if !options.kind_of?(Hash)
        options = { :validate => options }
    end
    options = Kernel.validate_options options,
        :validate => true, :define_dummy_types => false


    if name.respond_to?(:to_str)
        if File.file?(name) && File.extname(name) == ".orogen"
            register_orogen_file(name)
            name = File.basename(name, ".orogen")
        end

        if tasklib = used_task_libraries.find { |lib| lib.name == name }
            return tasklib
        end
        tasklib = load_task_library(name, options)
    else
        tasklib = name
    end

    tasklib.self_tasks.each do |t|
        tasks[t.name] = t
    end
    used_task_libraries << tasklib
    if self.typekit
        typekit.using_library(tasklib.tasklib_pkg_name, :link => false)
    end

    max_sizes.merge!(tasklib.max_sizes) do |typename, a, b|
        a.merge(b)
    end

    # Now import the typekits the project also imports, and the
    # tasklib's own typekit if there is one
    if tasklib.typekit
        using_typekit tasklib.typekit
    end
    tasklib.used_typekits.each do |tk|
        using_typekit tk
    end
    tasklib
end

#using_typekit(typekit) ⇒ Object

Import an orogen-generated typekit to be used by this project. The typekit is searched by name through the pkg-config tool. It means that, if PREFIX is the installation prefix where the project is installed, then

PREFIX/lib/pkgconfig

must be listed in the PKG_CONFIG_PATH environment variable.



491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
# File 'lib/orogen/gen/project.rb', line 491

def using_typekit(typekit)
    if typekit.respond_to?(:to_str)
        if tk = used_typekits.find { |tk| tk.name == typekit }
            return tk
        end
        typekit = import_typekit(typekit)
    elsif used_typekits.include?(typekit)
        return typekit
    end

    used_typekits << typekit
    if ours = self.typekit
        ours.using_typekit(typekit)
    end
    if typekit.respond_to?(:project)
        max_sizes.merge!(typekit.project.max_sizes) do |typename, a, b|
            a.merge(b)
        end
    end
    registry.merge(typekit.registry)
    opaque_registry.merge(typekit.opaque_registry)
    opaques.concat(typekit.opaques)
    typekit
end

#validate_max_sizes_specObject



208
209
210
211
212
213
214
# File 'lib/orogen/gen/project.rb', line 208

def validate_max_sizes_spec
    max_sizes.dup.each do |type, sizes|
        type = intermediate_type_for(type)
        sizes = Spec::Port.validate_max_sizes_spec(type, sizes)
        max_sizes[type.name].merge!(sizes)
    end
end

#xenomai?Boolean

True if the orocos target is xenomai

Returns:

  • (Boolean)


122
# File 'lib/orogen/gen/project.rb', line 122

def xenomai?; orocos_target == 'xenomai' end