Ignore:
Timestamp:
Apr 8, 2016, 3:40:57 PM (5 years ago)
Author:
Bayard Gildas
Message:

sources reformatted with flair-format-dir script

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairCore/src/FrameworkManager.cpp

    r2 r15  
    2626using namespace flair::gui;
    2727
    28 namespace
    29 {
    30     flair::core::FrameworkManager* frameworkmanager=NULL;
     28namespace {
     29flair::core::FrameworkManager *frameworkmanager = NULL;
    3130}
    3231
     32namespace flair {
     33namespace core {
    3334
    34 namespace flair
    35 {
    36 namespace core
    37 {
     35FrameworkManager *getFrameworkManager(void) { return frameworkmanager; }
    3836
     37bool IsBigEndian(void) {
     38  union {
     39    uint32_t i;
     40    char c[4];
     41  } bint = {0x01020304};
    3942
    40 FrameworkManager* getFrameworkManager(void) {
    41     return frameworkmanager;
     43  if (bint.c[0] == 1) {
     44    return true;
     45  } else {
     46    return false;
     47  }
    4248}
    4349
    44 bool IsBigEndian(void) {
    45     union {
    46         uint32_t i;
    47         char c[4];
    48     } bint = {0x01020304};
     50FrameworkManager::FrameworkManager(string name)
     51    : Object(NULL, name, XML_ROOT_TYPE) {
     52  if (frameworkmanager != NULL) {
     53    Err("FrameworkManager should be instanced only one time\n");
     54    return;
     55  }
    4956
    50     if(bint.c[0] == 1) {
    51         return true;
    52     } else {
    53         return false;
    54     }
    55 }
    56 
    57 FrameworkManager::FrameworkManager(string name): Object(NULL,name,XML_ROOT_TYPE)
    58 {
    59     if(frameworkmanager!=NULL) {
    60         Err("FrameworkManager should be instanced only one time\n");
    61         return;
    62     }
    63 
    64     Printf(SVN_REV);
    65     frameworkmanager=this;
    66     pimpl_=new FrameworkManager_impl(this,name);
     57  Printf(SVN_REV);
     58  frameworkmanager = this;
     59  pimpl_ = new FrameworkManager_impl(this, name);
    6760}
    6861
    6962FrameworkManager::~FrameworkManager() {
    70     //Printf("destruction FrameworkManager\n");
     63  // Printf("destruction FrameworkManager\n");
    7164
    72     //stop ui_com thread (which sends datas for graphs), we do not need it as graphs will be destroyed
    73     if(getUiCom()!=NULL) {
    74         getUiCom()->SafeStop();
    75         getUiCom()->Join();
     65  // stop ui_com thread (which sends datas for graphs), we do not need it as
     66  // graphs will be destroyed
     67  if (getUiCom() != NULL) {
     68    getUiCom()->SafeStop();
     69    getUiCom()->Join();
     70  }
     71
     72  // we start by deleting threads (except pimpl which must be deleted at last)
     73  // (before deleting objects that could be used by the threads)
     74  // Printf("delete Threads\n");
     75  for (vector<const Object *>::iterator it = Childs()->begin();
     76       it < Childs()->end(); it++) {
     77    // Printf("child %i %s
     78    // %s\n",Childs()->size(),(*it)->ObjectName().c_str(),(*it)->ObjectType().c_str());
     79    if ((*it)->ObjectType() == "Thread") {
     80      if (*it != pimpl_) {
     81        // Printf("del\n");
     82        delete (Thread *)(*it);
     83        // Childs() vector has been modified, we start from beginning again
     84        // it will be incremented by the loop, so in fact we start again at
     85        // begin()+1
     86        // it is not a problem since begin is pimpl
     87        it = Childs()->begin();
     88        // Printf("del ok\n");
     89      }
    7690    }
     91  }
    7792
    78     //we start by deleting threads (except pimpl which must be deleted at last)
    79     // (before deleting objects that could be used by the threads)
    80     //Printf("delete Threads\n");
    81     for(vector<const Object*>::iterator it=Childs()->begin() ; it < Childs()->end(); it++ ) {
    82         //Printf("child %i %s %s\n",Childs()->size(),(*it)->ObjectName().c_str(),(*it)->ObjectType().c_str());
    83         if((*it)->ObjectType()=="Thread") {
    84             if(*it!=pimpl_) {
    85                 //Printf("del\n");
    86                 delete (Thread*)(*it);
    87                 //Childs() vector has been modified, we start from beginning again
    88                 //it will be incremented by the loop, so in fact we start again at begin()+1
    89                 //it is not a problem since begin is pimpl
    90                 it=Childs()->begin();
    91                 //Printf("del ok\n");
    92             }
    93         }
     93  // next we delete IODevice
     94  // (before deleting objects that could be used by the IODevice)
     95  // Printf("delete IODevices\n");
     96  for (vector<const Object *>::iterator it = Childs()->begin();
     97       it < Childs()->end(); it++) {
     98    // Printf("child %i %s
     99    // %s\n",Childs()->size(),(*it)->ObjectName().c_str(),(*it)->ObjectType().c_str());
     100    if ((*it)->ObjectType() == "IODevice") {
     101      // Printf("del\n");
     102      delete (IODevice *)*it;
     103      // Printf("del ok\n");
     104      // Childs() vector has been modified, we start from beginning again
     105      // it will be incremented by the loop, so in fact we start again at
     106      // begin()+1
     107      // it is not a problem since begin is pimpl (not an IODevice)
     108      it = Childs()->begin();
     109      // Printf("del ok\n");
    94110    }
     111  }
    95112
    96     //next we delete IODevice
    97     // (before deleting objects that could be used by the IODevice)
    98     //Printf("delete IODevices\n");
    99     for(vector<const Object*>::iterator it=Childs()->begin() ; it < Childs()->end(); it++ ) {
    100         //Printf("child %i %s %s\n",Childs()->size(),(*it)->ObjectName().c_str(),(*it)->ObjectType().c_str());
    101         if((*it)->ObjectType()=="IODevice") {
    102             //Printf("del\n");
    103             delete (IODevice*)*it;
    104             //Printf("del ok\n");
    105             //Childs() vector has been modified, we start from beginning again
    106             //it will be incremented by the loop, so in fact we start again at begin()+1
    107             //it is not a problem since begin is pimpl (not an IODevice)
    108             it=Childs()->begin();
    109             //Printf("del ok\n");
    110         }
    111     }
     113  // Printf("delete childs\n");
     114  // on efface les enfants en commencant par la fin
     115  // le ui_com puis FrameworkManager_impl est détruit en dernier
     116  // permet de garder l'uicom pour notifer des destructions
     117  while (Childs()->size() != 0) {
     118    // Printf("child %i %s
     119    // %s\n",Childs()->size(),Childs()->back()->ObjectName().c_str(),Childs()->back()->ObjectType().c_str());
     120    if (Childs()->back() != NULL)
     121      delete Childs()->back();
     122  }
    112123
    113 //Printf("delete childs\n");
    114     //on efface les enfants en commencant par la fin
    115     //le ui_com puis FrameworkManager_impl est détruit en dernier
    116     //permet de garder l'uicom pour notifer des destructions
    117     while(Childs()->size()!=0) {
    118         //Printf("child %i %s %s\n",Childs()->size(),Childs()->back()->ObjectName().c_str(),Childs()->back()->ObjectType().c_str());
    119         if(Childs()->back()!=NULL) delete Childs()->back();
    120     }
     124  // childs.clear();
    121125
    122     //childs.clear();
    123 
    124 //Printf("destruction FrameworkManager ok\n");
     126  // Printf("destruction FrameworkManager ok\n");
    125127}
    126128
    127 void FrameworkManager::SetupConnection(string address,uint16_t port,size_t rcv_buf_size) {
    128     pimpl_->SetupConnection(address,port,rcv_buf_size);
     129void FrameworkManager::SetupConnection(string address, uint16_t port,
     130                                       size_t rcv_buf_size) {
     131  pimpl_->SetupConnection(address, port, rcv_buf_size);
    129132}
    130133
    131134void FrameworkManager::SetupUserInterface(string xml_file) {
    132     pimpl_->SetupUserInterface(xml_file);
     135  pimpl_->SetupUserInterface(xml_file);
    133136}
    134137
    135 gui::TabWidget* FrameworkManager::GetTabWidget(void) const {
    136     return pimpl_->tabwidget;
     138gui::TabWidget *FrameworkManager::GetTabWidget(void) const {
     139  return pimpl_->tabwidget;
    137140}
    138141
    139142void FrameworkManager::UpdateSendData(const SendData *obj) {
    140     if(getUiCom()!=NULL) getUiCom()->UpdateSendData(obj);
     143  if (getUiCom() != NULL)
     144    getUiCom()->UpdateSendData(obj);
    141145}
    142146
    143147void FrameworkManager::BlockCom(void) {
    144     if(getUiCom()!=NULL) getUiCom()->Block();
     148  if (getUiCom() != NULL)
     149    getUiCom()->Block();
    145150}
    146151
    147152void FrameworkManager::UnBlockCom(void) {
    148     if(getUiCom()!=NULL) getUiCom()->UnBlock();
     153  if (getUiCom() != NULL)
     154    getUiCom()->UnBlock();
    149155}
    150156
    151157bool FrameworkManager::ConnectionLost(void) const {
    152     if(getUiCom()!=NULL) {
    153         return (getUiCom()->ConnectionLost()| pimpl_->connection_lost);
    154     } else {
    155         return false;
    156     }
     158  if (getUiCom() != NULL) {
     159    return (getUiCom()->ConnectionLost() | pimpl_->connection_lost);
     160  } else {
     161    return false;
     162  }
    157163}
    158164
    159165void FrameworkManager::SetupLogger(string log_path) {
    160     pimpl_->SetupLogger(log_path);
     166  pimpl_->SetupLogger(log_path);
    161167}
    162168
    163169void FrameworkManager::AddDeviceToLog(IODevice *device) {
    164     pimpl_->AddDeviceToLog(device);
     170  pimpl_->AddDeviceToLog(device);
    165171}
    166172
    167 void FrameworkManager::StartLog(void) {
    168     pimpl_->StartLog();
    169 }
     173void FrameworkManager::StartLog(void) { pimpl_->StartLog(); }
    170174
    171 void FrameworkManager::StopLog(void) {
    172     pimpl_->StopLog();
    173 }
     175void FrameworkManager::StopLog(void) { pimpl_->StopLog(); }
    174176
    175 bool FrameworkManager::IsLogging(void) const {
    176     return pimpl_->is_logging;
    177 }
     177bool FrameworkManager::IsLogging(void) const { return pimpl_->is_logging; }
    178178
    179179void FrameworkManager::DisableErrorsDisplay(bool value) {
    180     pimpl_->disable_errors=value;
     180  pimpl_->disable_errors = value;
    181181}
    182182
    183183bool FrameworkManager::IsDisplayingErrors(void) const {
    184     return !(pimpl_->disable_errors);
     184  return !(pimpl_->disable_errors);
    185185}
    186186
Note: See TracChangeset for help on using the changeset viewer.