Changeset 184 in pacpusframework for trunk


Ignore:
Timestamp:
Oct 23, 2013, 9:34:23 AM (11 years ago)
Author:
morasjul
Message:

Minor fixes.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/Pacpus/kernel/ComponentBase.h

    r182 r184  
    4545namespace pacpus {
    4646
    47 // Forward declarations.
    4847class ComponentManager;
     48
     49class InputInterfaceBase;
     50class OutputInterfaceBase;
    4951
    5052template <typename T, class C>
    5153class InputInterface;
    52 
    5354template <typename T, class C>
    5455class OutputInterface;
  • trunk/include/Pacpus/kernel/ComponentManager.h

    r146 r184  
    119119    bool createComponent(const QString& type, const QString& name);
    120120
     121    bool checkComponentConnection(const QString& componentName, const QString& connectionName);
    121122    bool createConnection(const QString& type, const QString& name, const QString& , int );
    122123
  • trunk/include/Pacpus/kernel/InputOutputInterface.h

    r182 r184  
    3939    }
    4040
    41     void customEvent(QEvent* event)
     41    void customEvent(QEvent * event)
    4242    {
    4343        // TODO check component state started
     
    8686        }
    8787
    88             // Add here new event type if needed
     88        // Add here new event type if needed
    8989
    9090        default:
     
    112112{
    113113public:
    114     OutputInterface(QString name, C * component):OutputInterfaceBase(name,component,component) {}
     114    OutputInterface(QString name, C * component)
     115        :OutputInterfaceBase(name,component,component)
     116    {}
    115117    ~OutputInterface() {}
    116118
    117119    // Used by Components to send data througth typed output
    118     void send(const T & data, road_time_t t = road_time(), road_timerange_t tr = 0)
     120    void send(const T & data, road_time_t t = road_time(), road_timerange_t tr = 0);
     121   
     122    void send(const T & data, road_time_t t, road_timerange_t tr)
    119123    {
    120124        // FIXME Data Shared
     
    138142};
    139143
    140 
    141144} // namespace pacpus
    142145
  • trunk/src/PacpusLib/ComponentManager.cpp

    r182 r184  
    1616
    1717using namespace pacpus;
    18 using namespace pacpus;
    1918
    2019DECLARE_STATIC_LOGGER("pacpus.core.ComponentManager");
     
    183182}
    184183
     184bool ComponentManager::checkComponentConnection(const QString& componentName, const QString& connectionName)
     185{
     186    if (NULL == getComponent(componentName)) {
     187        LOG_WARN("cannot make connection : component " << componentName << " not found");
     188        return false;
     189    }
     190    if (NULL == getComponent(componentName)->getOutput(connectionName)) {
     191        LOG_WARN("cannot make connection : component " << componentName << " does not have input/output " << connectionName);
     192        return false;
     193    }
     194    return true;
     195}
     196
    185197bool ComponentManager::createConnection(const QString& outputSignature, const QString& inputSignature, const QString& type, int priority = 0)
    186198{
     199    // FIXME: use 2 signatures (output component + output connection) instead of 1 separated by a (".") dot
    187200    QStringList output = outputSignature.split(".");
    188201    QStringList input  = inputSignature.split(".");
    189202
    190     if (getComponent(output[0])==NULL) {
    191         LOG_WARN("cannot make connection : component " << output[0] << " not found");
    192         return false;}
    193     if (getComponent(output[0])->getOutput(output[1]) == NULL) {
    194         LOG_WARN("cannot make connection : component " << output[0] << " doesn't have output " << output[1]);
    195         return false;}
    196     if (getComponent(input[0])==NULL) {
    197         LOG_WARN("cannot make connection : component " << input[0] << " not found");
    198         return false;}
    199     if (getComponent(input[0])->getInput(input[1]) == NULL) {
    200         LOG_WARN("cannot make connection : component " << input[0] << " doesn't have intput " << input[1]);
    201         return false;}
    202 
     203    if (!checkComponentConnection(output[0], output[1])) {
     204        return false;
     205    }
     206    if (!checkComponentConnection(input[0], input[1])) {
     207        return false;
     208    }
    203209    // NOTE Create communicationInterface if needed ??
    204210    return connectInterface(
     
    207213        priority
    208214    );
    209 
    210215}
    211216
Note: See TracChangeset for help on using the changeset viewer.