Esempio n. 1
0
void Contact::display(void)
{
	IAddress* address = get_person()->get_address();
	std::cout << "\t" << get_person()->get_name() << std::endl;

	std::cout << "\t" << address->get_address1() << " " << address->get_address2() << std::endl;
	std::cout << "\t" << address->get_city() << " " << address->get_state() << ",  " << address->get_zipcode() << std::endl;
}
Esempio n. 2
0
int main(void)
{
  Family *first = NULL;                // Pointer to first person      
  Family *current = NULL;              // Pointer to current person    
  Family *last = NULL;                 // Pointer to previous person   
  char more = '\0';                    // Test value for ending input  

  while(true)
  {
    printf_s("\nDo you want to enter details of a%s person (Y or N)? ",
                                        first != NULL?"nother" : "");
    scanf_s(" %c", &more, sizeof(more));
    if(tolower(more) == 'n')
      break;

    current = get_person();

    if(first == NULL)
    {
      first = current;                // Set pointer to first Family  
      last = current;                 // Remember for next iteration  
    }
    else
    {
      last->next = current;   // Set next address for previous Family 
      current->previous = last;   // Set previous address for current 
      last = current;             // Remember for next iteration      
    }
  }

  show_people(true, first, last); // Tell them what we know 
  release_memory(first);
  first = last = NULL;
  return 0;
}
void employee::read()
{
	get_person();
	cout<<"\n\tSalary: ";
	cin>>salary;
	cout<<"\n\tDepartment: ";
	gets(department);
}
Esempio n. 4
0
int main(void)
{
  struct Family *first = NULL; /* Pointer to first person */
  struct Family *current = NULL; /* Pointer to current person */
  struct Family *last = NULL; /* Pointer to previous person */
  char more = '\0'; /* Test value for ending input */
  for( ; ; )
{
  printf("\nDo you want to enter details of a%s person (Y or N)? ",
  first != NULL?"nother" : "");
  scanf(" %c", &more);
  if(tolower(more) == 'n')
  break;
  current = get_person();
  if(first == NULL)
{
  first = current; /* Set pointer to first Family */
  last = current; /* Remember for next iteration */
}
else
{
  last->next = current; /* Set next address for previous Family */
  current->previous = last; /* Set previous address for current */
  last = current; /* Remember for next iteration */
}
}

/* Now tell them what we know */
/* Output Family data in reverse order */
  while (current != NULL)
{
  printf("\n%s was born %d/%d/%d, and has %s and %s as parents.",
  current->name, current->dob.day, current->dob.month,
  current->dob. year, current->father, current->mother );
  last = current; /* Save pointer to enable memory to be freed */
  current = current->previous; /* current points to previous list */
  free(last); /* Free memory for the Family we output */
}
return 0;
}
Esempio n. 5
0
US_SyncWithDB::US_SyncWithDB() : US_WidgetsDialog( 0, 0 )
{
   setAttribute  ( Qt::WA_DeleteOnClose );
   setWindowTitle( tr( "Synchronize Reports with Database" ) );
   setPalette    ( US_GuiSettings::frameColor() );
   setMinimumSize( 300, 160 );
   resize        ( 400, 200 );

   // Main layout
   QVBoxLayout* main = new QVBoxLayout( this );
   main->setContentsMargins( 2, 2, 2, 2 );
   main->setSpacing        ( 2 );

   // Top layout: buttons and fields above list widget
   QGridLayout* top  = new QGridLayout;
   int row           = 0;

   // Investigator
   // Only enable the investigator button for privileged users
   pb_invest = us_pushbutton( tr( "Select Investigator" ) );

   int invlev = US_Settings::us_inv_level();
   pb_invest->setEnabled( invlev > 0 );
   connect( pb_invest, SIGNAL( clicked() ), SLOT( get_person() ) );
   top->addWidget( pb_invest, row, 0 );

   QString name = ( invlev > 0 )
                  ? QString::number( US_Settings::us_inv_ID() ) + ": "
                  : "";

   le_invest = us_lineedit( name + US_Settings::us_inv_name(),
         -1, true );
   top->addWidget( le_invest, row++, 1 );

   // Instructions text
   te_desc   = us_textedit();
   us_setReadOnly( te_desc, true );
   QString desc = tr(
      "<b>Note:</b> Proceeding may result in local reports<br/>"
      "being replaced from the database.<ul>"
      "<li><b>Cancel</b>   to abort synchronizing from the DB.</li>"
      "<li><b>Download</b> to proceed with DB synchronization.</li>"
      "<li><b>New Only</b> to only download new DB records.</li></ul>" );
   te_desc->setHtml( desc );
   top->addWidget( te_desc,   row,   0, 4, 2 );

   main->addLayout( top );

   // Button Row
   QHBoxLayout* buttons    = new QHBoxLayout;
   QPushButton* pb_cancel  = us_pushbutton( tr( "Cancel" ) );
   QPushButton* pb_accept  = us_pushbutton( tr( "Download" ) );
   QPushButton* pb_newonly = us_pushbutton( tr( "New Only" ) );

   connect( pb_cancel,  SIGNAL( clicked() ), SLOT( cancelled() ) );
   connect( pb_accept,  SIGNAL( clicked() ), SLOT( accepted()  ) );
   connect( pb_newonly, SIGNAL( clicked() ), SLOT( downnew()   ) );

   buttons->addWidget( pb_cancel  );
   buttons->addWidget( pb_accept  );
   buttons->addWidget( pb_newonly );

   main->addLayout( buttons );

}
int main ( int argc, char *argvv[] )
{
   int status;
   void look_thread (), get_person (), get_bind();

   argv = argvv;


   /* Get binding information of the phone server.                            */
   status = pthread_create ( &phon_bind_thread_h, pthread_attr_default,
                             ( pthread_startroutine_t )get_bind,
                             ( pthread_addr_t ) 1 );
   THRCHK ( status );

   /* Get binding information of the address server.                          */
   get_bind ( 2 );

   /* Wait for all binding   threads to terminate.                            */
   status = pthread_join ( phon_bind_thread_h, NULL );
   THRCHK ( status );

   /* Free the storage being used by the binding   threads.                   */
   status = pthread_detach ( &phon_bind_thread_h );
   THRCHK ( status );


   /* Initialize condition variable mutex.                                    */
   status = pthread_mutex_init ( &name_mutex, pthread_mutexattr_default );
   THRCHK ( status );

   /* Initialize condition variable.                                          */
   status = pthread_cond_init ( &name_ready, pthread_condattr_default );
   THRCHK ( status );

   /* Initialize condition variable predicate.                                */
   name_ready_p = APP_LOOKUP;


   /* Create a thread to do a phone number lookup in a server.                */
   status = pthread_create ( &phon_thread_h, pthread_attr_default,
                             ( pthread_startroutine_t )look_thread,
                             ( pthread_addr_t ) 1 );
   THRCHK ( status );

   /* Create a thread to do an address lookup in a server.                    */
   status = pthread_create ( &addr_thread_h, pthread_attr_default,
                             ( pthread_startroutine_t )look_thread,
                             ( pthread_addr_t ) 2 );
   THRCHK ( status );

   /* Get input of a person's name.                                          */
   get_person ( );

   /* Wait for all remaining threads to terminate.                            */
   status = pthread_join ( phon_thread_h, NULL );
   THRCHK ( status );
   status = pthread_join ( addr_thread_h, NULL );
   THRCHK ( status );

   /* Free the storage being used by the remaining threads.                   */
   status = pthread_detach ( &phon_thread_h );
   THRCHK ( status );
   status = pthread_detach ( &addr_thread_h );
   THRCHK ( status );

   printf ( "Thanks for using %s !\n", argv[ 0 ] );
}
Esempio n. 7
0
US_SelectEdits::US_SelectEdits( bool dbase, QStringList& edIDs )
 : US_WidgetsDialog( 0, 0 ), editIDs( edIDs )
{
   sel_db        = dbase;

   setWindowTitle( tr( "Select Run(s) with Edits as Models Pre-Filter (%1)" )
         .arg( sel_db ? "DB" : "Local" ) );
   setPalette    ( US_GuiSettings::frameColor() );
   setMinimumSize( 480, 300 );

   // Main layout
   QVBoxLayout* main = new QVBoxLayout( this );
   main->setContentsMargins( 2, 2, 2, 2 );
   main->setSpacing        ( 2 );

   // Top layout: buttons and fields above list widget
   QGridLayout* top  = new QGridLayout;
   int ddstate       = sel_db ? US_Disk_DB_Controls::DB
                              : US_Disk_DB_Controls::Disk;

   dkdb_cntrls         = new US_Disk_DB_Controls( ddstate );
   connect( dkdb_cntrls, SIGNAL( changed       ( bool ) ),
            this,        SLOT  ( update_disk_db( bool ) ) );

   pb_invest           = us_pushbutton( tr( "Select Investigator" ) );
   if ( US_Settings::us_inv_level() < 3 )
      pb_invest->setEnabled( false );
   QString invnum      = QString::number( US_Settings::us_inv_ID() ) + ": ";
   QString invusr      = US_Settings::us_inv_name();
   le_invest           = us_lineedit( invnum + invusr, 0, true );
   connect( pb_invest, SIGNAL( clicked()    ),
                       SLOT  ( get_person() ) );

   // Search line
   QLabel* lb_filtdata = us_label( tr( "Search" ) );
   le_dfilter          = us_lineedit();

   int row           = 0;
   top->addLayout( dkdb_cntrls, row++, 0, 1, 4 );
   top->addWidget( pb_invest,   row,   0, 1, 2 );
   top->addWidget( le_invest,   row++, 2, 1, 2 );
   top->addWidget( lb_filtdata, row,   0, 1, 1 );
   top->addWidget( le_dfilter,  row++, 1, 1, 3 );

   connect( le_dfilter,  SIGNAL( textChanged( const QString& ) ),
                         SLOT  ( search     ( const QString& ) ) );

   main->addLayout( top );

   QFont font( US_GuiSettings::fontFamily(), US_GuiSettings::fontSize() );

   QStringList headers;
   headers << "Run" << "Date" << "dbID" << "Label";
   tw_data = new QTableWidget( 20, 4, this );
   tw_data->setFrameStyle ( QFrame::NoFrame );
   tw_data->setPalette    ( US_GuiSettings::editColor() );
   tw_data->setFont       ( font );
   tw_data->setSelectionMode    ( QAbstractItemView::ExtendedSelection );
   tw_data->setSelectionBehavior( QAbstractItemView::SelectRows );
   tw_data->setHorizontalHeaderLabels( headers );
   tw_data->verticalHeader()->hide();
   tw_data->setShowGrid   ( false );
   tw_data->setColumnWidth( 0, 250 );
   tw_data->setColumnWidth( 1, 100 );
   tw_data->setColumnWidth( 2,  50 );
   tw_data->setColumnWidth( 3, 350 );

   main->addWidget( tw_data );

   // Button Row
   QHBoxLayout* buttons = new QHBoxLayout;

   QPushButton* pb_help = us_pushbutton( tr( "Help" ) );
   connect( pb_help, SIGNAL( clicked() ), SLOT( help() ) );
   buttons->addWidget( pb_help );

   QPushButton* pb_cancel = us_pushbutton( tr( "Cancel" ) );
   connect( pb_cancel, SIGNAL( clicked() ), SLOT( cancelled() ) );
   buttons->addWidget( pb_cancel );

   QPushButton* pb_accept = us_pushbutton( tr( "Select PreFilter(s)" ) );
   connect( pb_accept, SIGNAL( clicked() ), SLOT( accepted() ) );
   buttons->addWidget( pb_accept );

   main->addLayout( buttons );

   // List from disk or db source
   list_data();
   resize( 720, 360 );
}