Changeset 42 in pacpusframework for trunk/src/PacpusLib/ComponentBase.cpp


Ignore:
Timestamp:
Jan 8, 2013, 9:44:51 PM (12 years ago)
Author:
sgosseli
Message:
  • Coding style
  • License header
  • Some clean-up
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/PacpusLib/ComponentBase.cpp

    r31 r42  
    11/**
    22 *
    3  * Distributed under the UTC Heudiascy Pacpus License, Version 1.0.
    4  * Copyright (c) UTC Heudiasyc 2010 - 2013. All rights reserved.
    5  *
    6  * See the LICENSE file for more information or a copy at:
    7  *   http://www.hds.utc.fr/~kurdejma/LICENSE_1_0.txt
    8  *
     3 * This file is part of the PACPUS framework distributed under the
     4 * CECILL-C License, Version 1.0.
     5 *
     6 * @author  Samuel Gosselin
     7 * @date    December, 2012
     8 * @version $Id$
     9 * @copyright Copyright (c) UTC/CNRS Heudiasyc 2005 - 2013. All rights reserved.
     10 *
    911 */
    1012
     
    1820
    1921ComponentBase::ComponentBase(const QString& name)
     22  : componentName(name)
     23  , recording(true)
     24  , THREAD_ALIVE(true)
     25  , mIsActive(false)
     26  , mgr(NULL)
     27  , componentState_(NOT_MONITORED)
    2028{
    2129    LOG_TRACE("constructor");
    22 
    23     configuration_ = NOT_CONFIGURED;
    24     componentName = name;
    25     recording = true;
    26     THREAD_ALIVE = true;
    27     mIsActive = 0;
    28     componentState_ = ComponentBase::NOT_MONITORED;
    29 
    30     // we get a pointer on the instance of ComponentManager
     30    // Get a pointer on the instance of ComponentManager.
    3131    mgr = ComponentManager::getInstance();
    32 
    33     LOG_INFO("component " << componentName
    34              << " was created"
    35              );
     32    LOG_INFO("component " << componentName << " was created");
    3633}
    3734
     
    4340int ComponentBase::startComponent()
    4441{
    45     if (mIsActive == 0) {
    46         mIsActive = 1;
    47         startActivity();
    48         return 1;
    49     } else {
    50         return 0;
    51     }
     42    if (mIsActive)
     43      return false;
     44     
     45    mIsActive = true;
     46    startActivity();
     47   
     48    return true;
    5249}
    5350
    5451int ComponentBase::stopComponent()
    5552{
    56     if (mIsActive == 1) {
    57         mIsActive = 0;
    58         stopActivity();
    59         return 1;
    60     } else {
    61         return 0;
    62     }
     53    if (!mIsActive)
     54      return false;
     55
     56    mIsActive = false;
     57    stopActivity();
     58   
     59    return true;
    6360}
    6461
    6562void ComponentBase::setState(const COMPONENT_STATE state)
    6663{
    67     if (state != componentState_) {
    68         componentState_ = state;
    69     }
     64    componentState_ = state;
    7065}
    7166
     
    8277bool ComponentBase::isConfigured() const
    8378{
    84     return CONFIGURED_OK == configuration_;
     79    return configuration_ == CONFIGURED_OK;
    8580}
Note: See TracChangeset for help on using the changeset viewer.