Savarese Software Research Corporation
GroupSessionOptions.cc
Go to the documentation of this file.
00001 /*
00002  * Copyright 2006-2009 Savarese Software Research Corporation
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     https://www.savarese.com/software/ApacheLicense-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #include <ssrc/wispers/group_session/GroupSessionOptions.h>
00018 #include <ssrc/wispers/lua/LoadConfig.h>
00019 
00020 __BEGIN_NS_SSRC_WSPR_GROUP_SESSION
00021 
00022 using std::string;
00023 
00024 GroupSessionOptions::GroupSessionOptions() :
00025   super(), _group_session_description("GroupSession")
00026 {
00027   using namespace boost::program_options;
00028 
00029   _group_session_description.add_options()
00030     ("gs-name,N",
00031      value<string>(&initializer.gs_name),
00032      "The user-facing application name of the group session service.")
00033     ("database,d",
00034      value<string>(&initializer.db_file),
00035      "The database filename used to store group session data.")
00036     ("db-properties",
00037      value<string>()->default_value(DEFAULT_CONFIG_FILE),
00038      "The database properties file used to configure group session database queries.")
00039     ("gs-poll-interval",
00040      value<unsigned int>(&initializer.gs_poll_interval)->default_value(300),
00041      "The number of seconds to poll for expired group sessions.")
00042     ("partition-id",
00043      value<unsigned int>(&initializer.partition_id)->default_value(0),
00044      "The partition identifier for the space of gsids served by the service.")
00045     ("num-partitions",
00046      value<unsigned int>(&initializer.num_partitions)->default_value(1),
00047      "The number of partitions deployed for the service protocol.")
00048     ("ids-per-expiration-message",
00049      value<unsigned int>(&initializer.ids_per_expiration_message)->default_value(2000),
00050      "The upper limit on the combined number of gsids and uids to include in a group session expiration message.");
00051 
00052   super::description.add(_group_session_description);
00053 }
00054 
00055 void GroupSessionOptions::notify(boost::program_options::variables_map & vm) {
00056   super::notify(vm);
00057   if(vm.count("gs-name") < 1)
00058     throw std::invalid_argument("missing gs-name");
00059   if(vm.count("database") < 1)
00060     throw std::invalid_argument("missing database");
00061   if(vm.count("db-properties") < 1)
00062     throw std::invalid_argument("missing group session properties");
00063   else {
00064     const NS_SSRC_WSPR_LUA::LoadConfig load(DEFAULT_MODULE_DIR);
00065     initializer.properties = std::move(*load(vm["db-properties"].as<string>()));
00066   }
00067 }
00068 
00069 __END_NS_SSRC_WSPR_GROUP_SESSION

Savarese Software Research Corporation
Copyright © 2006-2011 Savarese Software Research Corporation. All rights reserved.